1. Go to this page and download the library: Download mrubiosan/facade 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/ */
mrubiosan / facade example snippets
//First declare your facade class
namespace MyDummyNameSpace;
class Foo extends \Mrubiosan\Facade\FacadeAccessor
{
public static function getServiceName()
{
return 'foo'; //This is the name of the service in your container
}
}
//Then initialize the facade system
$exampleContainer = new \ArrayObject([
'foo' => new \DateTime(),
]);
$psrAdaptedContainer = new \Mrubiosan\Facade\ServiceLocatorAdapter\ArrayAccessAdapter($exampleContainer);
\Mrubiosan\Facade\FacadeLoader::init($psrAdaptedContainer, ['FooAlias' => 'MyDummyNameSpace\Foo']);
//Ready to use
echo \MyDummyNameSpace\Foo::getTimestamp();
echo \FooAlias::getTimestamp();