PHP code example of monkeyscloud / monkeyslegion-contracts

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

    

monkeyscloud / monkeyslegion-contracts example snippets


use MonkeysLegion\Contracts\ServiceProviderInterface;
use Psr\Container\ContainerInterface;

class MyPackageProvider implements ServiceProviderInterface
{
    public function getDefinitions(): array
    {
        return [
            MyService::class => fn() => new MyService(),
        ];
    }

    public function provides(): array
    {
        return [MyService::class];
    }

    public function context(): string
    {
        return 'all';
    }

    public function isDeferred(): bool
    {
        return false;
    }

    public function boot(ContainerInterface $container): void
    {
        // Post-build initialization
    }
}

use MonkeysLegion\Contracts\AbstractServiceProvider;

class MyPackageProvider extends AbstractServiceProvider
{
    public function getDefinitions(): array
    {
        return [
            MyService::class => fn() => new MyService(),
        ];
    }
}

Application::create($basePath)
    ->withProviders([YourPackageProvider::class])
    ->run();