PHP code example of glueful / api-skeleton
1. Go to this page and download the library: Download glueful/api-skeleton library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
glueful / api-skeleton example snippets
// Simple version prefix (customize as needed)
$router->group(['prefix' => 'v1'], function (Router $router) {
$router->get('/welcome', [WelcomeController::class, 'index']);
$router->get('/status', [WelcomeController::class, 'status']);
});
// Other prefix options:
// - 'v1' → /v1/...
// - '/api/v1' → /api/v1/...
// - api_prefix($context) → uses config/api.php settings
#[Controller(prefix: '/api/v1')]
class UserController extends BaseController
{
#[Get('/users/{id}')]
public function show(int $id): Response { }
}
bash
# Install dependencies
composer install
# Initialize application (runs migrations, generates key)
php glueful install --quiet
# Start development server
php glueful serve
# Visit the API
curl http://127.0.0.1:8080/v1/welcome
curl http://127.0.0.1:8080/health
api-skeleton/
├── app/ # Application code
│ ├── Controllers/ # HTTP request handlers
│ ├── Models/ # ORM models
│ └── Providers/ # Service providers
├── bootstrap/app.php # Framework initialization
├── config/ # Configuration files
├── database/migrations/ # Database migrations
├── public/index.php # HTTP entry point
├── routes/api.php # API routes
├── storage/ # Runtime data (logs, cache, db)
└── tests/ # PHPUnit tests