PHP code example of mtymek / modular-expressive

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

    

mtymek / modular-expressive example snippets


// index.php
use ModularExpressive\ModularApplicationFactory;

$appFactory = new ModularApplicationFactory();
$app = $appFactory->create(
     // system configuration, similar to ZF2
    [
        'modules' => [
            'Application',
            'AnotherModule'
        ],
        'module_listener_options' => [
            'config_glob_paths' => [
                'config/autoload/{{,*.}global,{,*.}local}.php',
            ],
        ]
    ]
);
$app->run();

namespace Application;

class Module
{
    public function getConfig()
    {
        return 

return [
    'module_listener_options' => [
        'config_glob_paths' => [
            __DIR__ . '/autoload/{,*.}{global,local}.php'
        ],

        'config_cache_enabled' => true,
        'config_cache_key' => 'config',
        'cache_dir' => 'data/cache',
    ],
];

use Zend\ModuleManager\Listener\ConfigListener;
use Zend\ModuleManager\Listener\InitTrigger;
use Zend\ModuleManager\Listener\ModuleResolverListener;
use Zend\ModuleManager\ModuleManager;

$moduleManager = new ModuleManager([]);
$moduleManager->getEventManager()->attach(
    ModuleEvent::EVENT_LOAD_MODULE_RESOLVE, new ModuleResolverListener()
);
$this->moduleManager->getEventManager()->attach(
    ModuleEvent::EVENT_LOAD_MODULE, new InitTrigger()
);

// inject custom manager into application factory
$appFactory = new ModularApplicationFactory($moduleManager);

namespace Application;

class Module
{
    public function getConfig()
    {
        return