PHP code example of sageit / phalcon-micro-annotations

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

    

sageit / phalcon-micro-annotations example snippets


namespace App\Service;

class Router implements \Phalcon\Di\ServiceProviderInterface
{

    public function register(\Phalcon\Di\DiInterface $di): void
    {
        $di->setShared(
            'router',
            function () use ($di) {
                return new \Phalcon\Mvc\Router\Annotations\MicroRouter($di, (object) [
                    "adapter" => "apcu",
                    "directory" => "app/controllers/",
                    "namespace" => "App\Controllers",
                    "lifetime" => 21600000,
                    "cachedirectory" => "/app/storage/cache/annotations/"
                ]);
            }
        );
    }
}

$this->getDI()->get('router')->mountMicro($this);

"adapter" => "apcu",
"lifetime" => 21600000,

"adapter" => "stream",
"cachedirectory" => "/app/storage/cache/annotations/"

"adapter" => "memory"

clearCache()

$this->getDI()->get('router')->clearCache();