PHP code example of geekmusclay / framework

1. Go to this page and download the library: Download geekmusclay/framework 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/ */

    

geekmusclay / framework example snippets


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);
}