geekmusclay / framework
0.3.1
2023-12-19 14:54 UTC
Requires
- php: ^8.0
- geekmusclay/di-container: ^0.1
- geekmusclay/orm: ^0.4.0
- geekmusclay/router: ^0.6.0
- guzzlehttp/psr7: ^2.4
- http-interop/response-sender: ^1.0
- twig/twig: ^3.4
Requires (Dev)
- laminas/laminas-coding-standard: ^2.4
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5
- symfony/var-dumper: ^5.4
This package is auto-updated.
Last update: 2024-10-19 15:13:56 UTC
README
Setup
Create a .htaccess
file with :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L,NC]
Create a .env
file with :
APP_ENV=dev
DATABASE_URL=mysql:host=localhost;dbname=test
DATABASE_USER=root
DATABASE_PASSWORD=
In an index.php
file :
use Geekmusclay\DI\Core\Container; use Modules\Blog\BlogModule; use GuzzleHttp\Psr7\ServerRequest; use Geekmusclay\Framework\Core\App; use Geekmusclay\Framework\Core\DotEnv; use Geekmusclay\Router\Core\Router; use Geekmusclay\Router\Interfaces\RouterInterface; use function Http\Response\send; $env = getenv('APP_ENV'); $path = __DIR__ . '/.env'; if ((false === $env || $env === 'dev') && is_file($path)) { // Loading environement variables DotEnv::load($path); } // Instanciate application DI Container $container = new Container(); // Register application router into container $router = $container->get(Router::class, [$container]); // Register our router as RouterInterface for injections $container->set(RouterInterface::class, $router); $app = new App($container, [ BlogModule::class ]); $app->get('/', function () { return new Response(200, [], 'Welcome on my app'); }); $response = $app->run(ServerRequest::fromGlobals()); try { $response = $app->run(ServerRequest::fromGlobals()); } catch (Throwable $e) { dd($e); }