PHP code example of phpnomad / loader

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

    

phpnomad / loader example snippets




use PHPNomad\Core\Bootstrap\CoreInitializer;
use PHPNomad\Di\Container\Container;
use PHPNomad\Loader\Bootstrapper;

$container = new Container();

(new Bootstrapper(
    $container,
    new CoreInitializer(),
    new WordPressInitializer(),
    new MyAppInitializer()
))->load();



use PHPNomad\Events\Interfaces\HasListeners;
use PHPNomad\Loader\Interfaces\HasClassDefinitions;

final class MyAppInitializer implements HasClassDefinitions, HasListeners
{
    public function getClassDefinitions(): array
    {
        return [
            PostRepository::class => PostRepositoryInterface::class,
        ];
    }

    public function getListeners(): array
    {
        return [
            PostPublished::class => SendNotificationOnPublish::class,
        ];
    }
}