GithubHelp home page GithubHelp logo

albertodevel / simple-php-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from panique/simple-php-api

0.0 1.0 0.0 4 KB

An extremely simple API (with authentication) example, written in PHP (server) and JS (client), using JSON

PHP 50.73% Shell 49.27%

simple-php-api's Introduction

simple-php-api (in under 40 lines of code)

An extremely simple API (with authentication) example, written in PHP on top of the excellent Slim micro framework. This repo shows the "server", meaning the part that offers the data. There's another repo (https://github.com/panique/simple-php-api-client) showing a "client", meaning the part that GETS the data.

What's inside ?

The entire API is inside index.php, but it's using the micro framework Slim and an authentication module. The .htaccess creates these nice-looking URLs like /api/test, that's actually part of Slim.

How to install

Manual installation:

Put index.php, composer.json and .htaccess from the application folder inside your server. As this API uses "beautiful URLs" (like /api/stuff, not index.php?path=api&...), make sure you have mod_rewrite activated (when using Apache) and set your virtualhost to "AllowOverride All". If you don't know what this means, better use the automatic installation:

Automatic installation:

For simple setup, this project comes with a full installer which sets up a Ubuntu 14.04 LTS Vagrant box and installs Apache, PHP5, Composer etc. and sets up the application. To do so, go to where the Vagrantfile is and do a "vagrant up" on the console. Your application is then reachable under 192.168.33.44

How to use

After installing, check the API which a browser, when using the auto-installer you can do that under http://192.168.33.44/api/test, you'll be asked to enter your login (username: demouser, password: 123) and get back a JSON string. Nice!

Real-world use

For real use, you or somebody else will probably access this API remotely with a client, plase have a look at my other repo https://github.com/panique/simple-php-api-client which shows exactly how to access this API from the outside, also in PHP.

License

MIT, do whatever you want with it.

The MIT License (MIT)

Copyright (c) 2016 panique

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Like what you see ?

I'm also blogging at https://www.dev-metal.com, also find my others repos here: https://github.com/panique !

simple-php-api's People

Contributors

panique avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.