district5 / slim-s4s
District5 Slim Framework 4 Stub
0.3.2
2024-11-25 17:53 UTC
Requires
- php: >=8.1
- php-di/php-di: 7.*
- slim/http: *
- slim/php-view: *
- slim/psr7: *
- slim/slim: 4.*
Requires (Dev)
- phpunit/phpunit: 9.*
README
This library provides Slim Framework 4 utilities for initialising and maintaining both Slim4 JSON based API's and lightweight UI based apps.
Usage
These instructions assume a standard app directory structure:
- app
| - api
| | - routes
| - www
| | - routes
- lib
| - ...
initialiser.php
Set Environment
Setting an environment, which can be accessed by routing apps:
\S4S\Slim4\Factory\AppFactory::setEnvironment(\S4S\Slim4\Enum\Environment::\S4S\Slim4\Enum\Development);
JSON API base App
$base = __DIR__ . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR; $app = AppFactory::createJsonApi($base . 'api'); $app->run();
UI base App
$base = __DIR__ . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR; $app = AppFactory::createUI($base . 'www'); $app->run();