1. Go to this page and download the library: Download blast/facades 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/ */
blast / facades example snippets
use Blast\Facades\FacadeFactory;
use League\Container\Container;
$container = new Container();
FacadeFactory::setContainer($container);
//add our service
$container->add('Acme\Service', 'Acme\Service\SomeService');
//returns an instance of Acme\Service\SomeService
$container->get('Acme\Service');
//add our service
$container->add('Acme\Service\SomeService');
//returns an instance of Acme\Service\SomeService
$container->get('Acme\Service\SomeService');
//returns an instance of Acme\Service\SomeService without registration
$container->get('Acme\Service\SomeService');
namespace Acme\Facades\Service;
use Blast\Facades\AbstractFacade;
use Acme\Service;
class Service extends AbstractFacade
{
protected static function accessor()
{
return Acme\Service::class;
}
}
use Acme\Facades\Service;
//is returning the service instance
$service = Service::__instance();
use Acme\Facades\Service;
Service::someMethod();
use Acme\Facades\Service;
//is returning the service instance
$service = Service::__instance();
$service->someMethod();
use Acme\Facades\Service;
forward_static_call([Service::class, 'someMethod']);
use Acme\Facades\Service;
call_user_func(sprintf('%s::%s', Service::class, 'someMethod'));
use Acme\Facades\Service;
//add a service
$container->add('Acme\Service', 'Acme\Service\SomeService');
//is returning the service instance Acme\Service\SomeService
$service = Service::__instance();
//replace a service with another one
$container->add('Acme\Service', 'Acme\Service\AnotherService');
//is now returning the service instance Acme\Service\AnotherService
$service = Service::__instance();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.