Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gxiang314/php-api
https://github.com/gxiang314/php-api
Last synced: about 6 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/gxiang314/php-api
- Owner: GXiang314
- Created: 2024-03-12T20:18:26.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-03-12T20:37:31.000Z (8 months ago)
- Last Synced: 2024-03-12T21:39:30.753Z (8 months ago)
- Language: PHP
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PHP simplest API Template
##### quick start:
```shell
composer install
composer start # run php server http://localhost:8000
```##### api response demo:
http://localhost:8000/api/demo
```json
{
"code": 200,
"data": [
{
"id": 1,
"name": "John"
},
{
"id": 2,
"name": "Allen"
}
],
"message": "ok.",
"execution_time": 0.0009458065032958984
}
```##### route register:
```php
# ./src/public/index.php
# callback function
$app->router->get('path/{var}', function() {
return json_encode(['data' => '1234'])
})# class method
$app->router->post('path', [DemoController::class, 'methodName'])
```