All Projects → panique → simple-php-api

panique / simple-php-api

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

Programming Languages

PHP
23972 projects - #3 most used programming language
shell
77523 projects
ApacheConf
554 projects

Projects that are alternatives of or similar to simple-php-api

purescript-swerve
Swerve is a library that offers a type-level DSL for describing server and client web applications. Inspired by Haskell's Servant library.
Stars: ✭ 20 (-13.04%)
Mutual labels:  api-client, api-server
Php Crud Api
Single file PHP script that adds a REST API to a SQL database
Stars: ✭ 2,904 (+12526.09%)
Mutual labels:  api-server, php-api
pimba
Pimba is a minimalist command-line tool written in Go to publish and serve static files.
Stars: ✭ 12 (-47.83%)
Mutual labels:  api-client, api-server
Openapi Generator
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
Stars: ✭ 10,634 (+46134.78%)
Mutual labels:  api-client, api-server
drowsy
😪 Lazy integrations tool for RESTful interfaces to aid POC development and streamline integrations
Stars: ✭ 19 (-17.39%)
Mutual labels:  api-client, api-server
noire-server
Hapi Boilerplate
Stars: ✭ 20 (-13.04%)
Mutual labels:  api-client, api-server
webapi
WAI based library for web api
Stars: ✭ 27 (+17.39%)
Mutual labels:  api-client, api-server
ContextIO-node
[DEPRECATED] - Official Node.js client library for the Context.IO Email API
Stars: ✭ 86 (+273.91%)
Mutual labels:  api-client
radiobrowser4j
RadioBrowser Java API library
Stars: ✭ 30 (+30.43%)
Mutual labels:  api-client
nodejs-passdock
PassDock API methods for iOS Wallet (PassBook)
Stars: ✭ 13 (-43.48%)
Mutual labels:  api-client
youtube-deno
A Deno client library of the YouTube Data API.
Stars: ✭ 30 (+30.43%)
Mutual labels:  api-client
go-kkbox
KKBOX Open API SDK for Golang.
Stars: ✭ 16 (-30.43%)
Mutual labels:  api-client
openweathermap-java-api
Java API to access openweathermap.org API
Stars: ✭ 19 (-17.39%)
Mutual labels:  api-client
fusionauth-typescript-client
A TypeScript client for FusionAuth
Stars: ✭ 37 (+60.87%)
Mutual labels:  api-client
api-server
📡 API server for api.cdnjs.com - The #1 free and open source CDN built to make life easier for developers.
Stars: ✭ 48 (+108.7%)
Mutual labels:  api-server
thetvdb2
Thetvdb.com API v2 Client
Stars: ✭ 33 (+43.48%)
Mutual labels:  api-client
nodejs-searchitunes
Lightweight node.js module to quickly search Apple's iTunes Store for music, movies, apps, etc.
Stars: ✭ 25 (+8.7%)
Mutual labels:  api-client
cv4pve-api-dotnet
Proxmox VE Client API .Net C#
Stars: ✭ 25 (+8.7%)
Mutual labels:  api-client
accessibility-cloud
👩🏽‍🦯🦮👩🏻‍🦽👩🏿‍🦼 the platform to exchange physical accessibility data in a standardized, future-proof, easy-to-use way.
Stars: ✭ 37 (+60.87%)
Mutual labels:  api-server
go-amazon-product-advertising-api
Go Client Library for Amazon Product Advertising API
Stars: ✭ 51 (+121.74%)
Mutual labels:  api-client

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 !

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].