1. Go to this page and download the library: Download hostkurd/flocms-api 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/ */
hostkurd / flocms-api example snippets
use FloCMS\Api\Kernel;
use FloCMS\Api\Router;
use FloCMS\Api\Middleware\CorsMiddleware;
use FloCMS\Api\Middleware\ExceptionMiddleware;
use FloCMS\Api\Middleware\JsonBodyMiddleware;
use FloCMS\Core\Http\Request;
use FloCMS\Core\Modules\ModuleSystem;
$router = new Router();
$router->group('/v1', function (Router $router): void {
$router->get('/health', fn () => ['status' => 'ok'])->name('health');
});
$kernel = new Kernel(
router: $router,
container: ModuleSystem::container(),
modules: ModuleSystem::manager(),
debug: false,
);
$kernel->middleware([
new CorsMiddleware(['https://www.example.com'], allowCredentials: true),
new ExceptionMiddleware(debug: false),
new JsonBodyMiddleware(),
]);
$kernel->handle(Request::fromGlobals())->send();
use FloCMS\Api\Router;
use App\Api\NewsController;
return static function (Router $router): void {
$router->get('/v1/news', [NewsController::class, 'index'])
->name('news.index')
->module('news');
};
'routes' => ['api' => 'routes/api.php'],
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.