PHP code example of decodelabs / monarch

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

    

decodelabs / monarch example snippets


use DecodeLabs\Monarch;

Monarch::setApplicationName('My Cool App');
Monarch::$paths->root = '/var/www/my-cool-app';
Monarch::$paths->run = '/var/www/my-cool-app/dist';
Monarch::$paths->localData = '/var/www/my-cool-app/data/local';
Monarch::$paths->sharedData = '/var/www/my-cool-app/data/shared';

use DecodeLabs\Monarch;

Monarch::$paths->alias('@components', '@root/components');
Monarch::$paths->alias('@assets', '@root/assets');

use DecodeLabs\Monarch;
$path = Monarch::$paths->resolve('@components/MyComponent.php');
// /var/www/my-cool-app/components/MyComponent.php

use DecodeLabs\Monarch;
use DecodeLabs\Pandora\Container;

if(Monarch::$container instanceof Container) {
    Monarch::$container->bind('myService', new MyService());
}

use DecodeLabs\Monarch;

$service = Monarch::$container->get('myService');