Download the PHP package anshu-krishna/api-framework without Composer
On this page you can find all versions of the php package anshu-krishna/api-framework. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package api-framework
API Framework
This is a simple API framework that can be used to create APIs.
Installation:
Quick Start Guide (using the provided sample code as example):
Let's create a simple API server and on the way learn how to use this framework.
See the sample directory for the full sample server code.
In this example we will assume that this server is running at https://api.sample.dev .
Files List:
Explanation of the listed files:
-
codebase-root/
This is the root directory of the codebase. (Choose any directory). -
codebase-root/api-funcs-base/
This is the directory where all the API definitions are stored. (Directory name does not need to beapi-funcs-base
. It can be anything.)-
@all.php
[Optional] This file is executed before all the APIs in this directory and its subdirectories. -
@index.php
[Optional] This file defines the API available at https://api.sample.dev -
Ping.php
This file defines the API available at https://api.sample.dev/ping -
Example/
This directory contains all APIs grouped under 'example' API.-
@all.php
[Optional] This file is executed before all the APIs in this directory and its subdirectories. -
@index.php
[Optional] This file defines the API available at https://api.sample.dev/example -
Adder.php
This file defines the API available at https://api.sample.dev/example.adder -
CamelCase/
This directory contains all APIs grouped under 'example.camel_case' API.-
@index.php
[Optional] This file defines the API available at https://api.sample.dev/example.camel_case Hello.php
This file defines the API available at https://api.sample.dev/example.camel_case.hello
-
-
-
-
codebase-root/public/
This is the public directory where the server is running. (i.e. https://api.sample.dev must point to this directory.) Directory name does not need to bepublic
. It can be anything.-
.htaccess
This file is used to rewrite the URLs to the API framework. index.php
This file is the entry point of the server.
-
Sample code for some of the files (with explanations/comments):
See the sample directory for the full sample server code.
Sample Requests and Responses:
Request:
https://api.sample.dev/ping
Response:
Request:
https://api.sample.dev/ping?msg=ABCD
or
https://api.sample.dev/ping
with POST data {"msg":"ABCD"}
or
https://api.sample.dev/ping/msg/ABCD
Response:
Request:
https://api.sample.dev/example.adder?add[]=1&add[]=2&add[]=3
or
https://api.sample.dev/example.adder
with POST data { "add" : [1,2,3] }
Response:
Request:
https://api.sample.dev/does_not_exist
Response:
Notes:
All versions of api-framework with dependencies
anshu-krishna/data-validator Version ^2.8.1
anshu-krishna/php-utilities Version ^2.2