hugsbrugs / php-api
PHP API Utilities
Requires
- firebase/php-jwt: ^6.8
- hugsbrugs/php-array: dev-master
- hugsbrugs/php-security: 0.1
- hugsbrugs/php-string: dev-master
- ircmaxell/password-compat: ^1.0
- peej/tonic: dev-php8.1-fixes
Requires (Dev)
- php-coveralls/php-coveralls: ^2.6.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-11-28 16:23:18 UTC
README
This librairy provides utilities function to group different API calls for a single project entry point. Based on Tonic.
Install
Install package with composer
composer require hugsbrugs/php-api
In your PHP code, load library
require_once __DIR__ . '/../vendor/autoload.php'; use Hug\Api\Api as Api;
Usage
Edit config.php
Set your parameters. Visit Tonic documentation for params.
Put dispatch.php and .htaccess files in api folder
If you want to access your API through /api subfolder, create this folder at your webroot directory and copy .htaccess (which will redirect all traffic to dispatch.php) and dispatch.php (which will route your API requests)
Create your API classes
Look at TestApi.php and create your API endpoints extending
Hug\Api\ApiResource
Based on Tonic syntax
Consume your API
In your browser visit your endpoints or do CURL requests to test POST, PUT, DELETE methods.
Changelog
28/09/2023 - Migration for PHP 8 Replace "peej/tonic" : "dev-master", By "neekfenwick/tonic" : "^3.4.1",
Author
Hugo Maugey visit my website ;)