PHP code example of codectrl-sro / apollo

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

    

codectrl-sro / apollo example snippets



// public/index.php

Apollo;
use CodeCTRL\Apollo\Core\Env;
use CodeCTRL\Apollo\UI\Html\Html;

$app = new Apollo();
$app->setBaseDir(dirname(__DIR__));
$app->setHomeDir(dirname(__DIR__));

if (Env::bool('APP_DEBUG', false)) {
    $app->allowErrorReporting();
}

// Fail at boot with a message naming the key, rather than deep inside a library later.
Env::assertRequired(['CRYPT_SECRET']);

Html::emit($app->run());


// config/route.php

use App\Modules\Home\HomeContainer;
use CodeCTRL\Apollo\Http\Strategies\HtmlStrategy;

return [
    'route' => [
        'debug'   => (bool)($_ENV['APP_DEBUG'] ?? false),
        'modules' => [],
        'session' => ['samesite' => 'Lax'],
    ],
    'routing' => [
        'basepath' => '/',
        'strategy' => HtmlStrategy::class,
        'paths'    => [
            '/' => [
                'methods' => [
                    'GET' => ['callable' => [HomeContainer::class, 'index'], 'name' => 'home'],
                ],
            ],
        ],
    ],
    'middleware' => [
        'groups' => [
            'web' => ['csrf', 'headers'],
            'api' => ['headers', 'throttle:60,60'],
        ],
    ],
];

Env::string('CRYPT_SECRET');          //  optional
Env::int('MAIL_SMTP_PORT', 587);
Env::bool('APP_DEBUG', false);

'/admin' => [
    ' => ['web'],
    'methods' => [
        'GET' => ['callable' => [AdminContainer::class, 'dashboard'], 'name' => 'admin.dashboard'],
    ],
    'paths' => [
        '/users' => [
            'middleware' => ['can:users,read'],
            'methods' => [
                'GET'  => ['callable' => [UserContainer::class, 'index'], 'name' => 'users.index'],
                'POST' => [
                    'callable'             => [UserContainer::class, 'store'],
                    '

'middleware' => [
    'aliases' => ['audit' => \App\Http\AuditMiddleware::class],
    'groups'  => ['web' => ['csrf', 'headers', 'audit']],
],

├── config/           # PHP files returning arrays; every one is loaded and merged
│   ├── route.php
│   ├── db.php
│   └── translations/
├── modules/          # your application modules
├── logs/             # written by the logger
├── public/
│   └── index.php
└── .env