webchimp / chapi
CHIMP API
Installs: 137
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
Requires
- ext-iconv: *
- ext-json: *
- firebase/php-jwt: ^5.5
- php-amqplib/php-amqplib: ^3.2
- webchimp/dabbie: dev-main
- webchimp/norm: >=2.0
Requires (Dev)
- phpstan/phpstan: ^1.7
README
Why
CHAPI stands for CHIMP API Powerful Integration (clever right?).
CHAPI is our take on how to manage an easy to use but still powerful API framework.
The objectives for CHAPI are:
- Elegant and simple for the programmer
- Flexible (CHAPI comes with a lot of automagic but its optional)
- Composer Compliant
Structure
CHAPI is aimed specifically to generate API's. This being said, the structure was created with RESTful implementations in mind. The main parts of CHAPI are the following:
Request Object
The request object lets you play with the request information made to the API. It comes with:
- Wrapper functions to manipulate
GET
,POST
orPUT
request information - Wrapper functions to use
$_SESSION
or$_FILES
- Wrapper functions to manipulate Cookies and Server information
- Tools to get Authorization Headers and bearers
Response Object
The Response Object is a tool designed to facilitate the way the endpoint responds. It contains special functions to:
- Set the response status
- Set the response body
- Set any header
- Redirect to special locations
- Respond json in an easy way
Router
CHAPI's Router is a very powerful tool. It comes with an engine that lets you add and resolve routes in a straight-forward way.
Main advantages of CHAPI's Router are:
- Easy create
GET
,POST
,PUT
andDELETE
routes - Named params
- Optional params
- Regex supported
Endpoint Class
The endpoint class uses all the power from Request, Response and Router. It creates a base to create endpoints without too much code. Out of the box, it comes with a specific set of automagic routes that define the basis for simple endpoints needed for CrUD operations and let you extend this however you want.
App Wrapper
Everything in CHAPI is wrapped, at the end, in an APP
object that lets you access everything it has through one point.