PHP code example of madewithlove / service-providers

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

    

madewithlove / service-providers example snippets


use League\Flysystem\FilesystemInterface;
use League\League\Container;
use Madewithlove\ServiceProviders\Bridges\LeagueContainerDecorator;
use Madewithlove\ServiceProviders\Filesystem\FlysystemServiceProvider;

$container = new LeagueContainerDecorator(new Container());
$container->addServiceProvider(new FlysystemServiceProvider(...)));

$filesystem = $container->get(FilesystemInterface::class);

$provider = new EloquentServiceProvider([
    'local' => [
        'driver' => 'sqlite',
        'etc' => 'etc,
    ],
    'production' => [
        'driver' => 'mysql',
        'etc' => 'etc,
    ],
]);

public function getServices()
{
    return ['my_alias' => new Alias('to_something_else')];
}

public function getServices()
{
    return ['views_path' => new Parameter(__DIR__.'/views)];
}

new ParametersServiceProvider([
    'foo' => 'bar',
    'bar' => 'baz',
]);

$container->get('foo'); // (string) "bar"

new PrefixedProvider('config', new ParametersServiceProvider([
    'foo' => 'bar',
]));

$container->get('config.foo'); // (string) "bar"

├── Bridges
│   └── LeagueContainerDecorator.php
├── CommandBus
│   └── TacticianServiceProvider.php
├── Console
│   └── SymfonyConsoleServiceProvider.php
├── Database
│   ├── EloquentServiceProvider.php
│   └── FactoryMuffinServiceProvider.php
├── Development
│   ├── DebugbarServiceProvider.php
│   └── MonologServiceProvider.php
├── Events
│   └── LeagueEventsServiceProvider.php
├── Filesystem
│   └── FlysystemServiceProvider.php
├── Http
│   ├── LeagueRouteServiceProvider.php
│   ├── RelayServiceProvider.php
│   └── ZendDiactorosServiceProvider.php
├── Templating
│   └── TwigServiceProvider.php
└── Utilities
    ├── Alias.php
    ├── Parameter.php
    ├── ParametersServiceProvider.php
    └── PrefixedProvider.php