PHP code example of alisa / framework

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

    

alisa / framework example snippets


// config/routes.php

return [
    'main', // файл main.php
    'foo/bar/baz', // папка foo, подпапка bar и файл с роутами baz.php
];

// routes/main.php

/** @var \Alisa\Alisa $alisa */

$alisa->onStart([\App\Controllers\HamsterController::class, 'start']);
$alisa->onAny([\App\Controllers\HamsterController::class, 'any']);

// routes/main.php

$alisa->onStart([\App\Controllers\HamsterController::class, 'start']);

...

// app/Controllers/HamsterController

namespace App\Controllers;

use Alisa\Context;

class HamsterController
{
    public function start(Context $context)
    {
        //
    }
}

// routes/main.php

$alisa->onStart(function (Context $context) {
    //
});

namespace App\Middlewares;

use Alisa\Context;

class LoggerMiddleware
{
    public function __invoke(Context $context, $next)
    {
        $next($context);
    }
}

$alisa->onStart([\App\Controllers\HamsterController::class, 'start'])->middleware(LoggerMiddleware::class);

$alisa
    ->onCommand('foo')
    ->middleware(function (Context $context, $next) {
        $next($context);
    });