PHP code example of flawlol / facade

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

    

flawlol / facade example snippets




namespace App\Facade;

use Flawlol\Facade\Abstract\Facade;

class MyFacade extends Facade
{
    protected static function getFacadeAccessor(): string
    {
        return 'my_service';
    }
}

use App\Facade\MyFacade;

$result = MyFacade::someMethod($arg1, $arg2);



namespace Flawlol\Facade;

use Flawlol\Facade\Abstract\Facade;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class FacadeBundle extends Bundle
{
    public function boot(): void
    {
        parent::boot();

        $container = $this->container;

        Facade::setContainer($container);
    }
}
 bin/console app:generate-facade-helpers



namespace App\Facade {
    class Arr
    {
        /**
         * @param array $array
         * @param string $keyPath
         * @param mixed $defaultValue
         * @return mixed
         */
        public static function get(array $array, string $keyPath, mixed $defaultValue = NULL): mixed
        {
            /** @var \App\Service\Common\Array\ArrayHelper $instance */
            return $instance->get($array, $keyPath, $defaultValue);
        }
    }
}



namespace App\Service\Common\Array;

class ArrayHelper
{
    public function get(array $array, string $keyPath, mixed $defaultValue = null): mixed
    {
        // implementation
    }
}

use App\Facade\Arr;

$result = Arr::get($array, 'key.path', 'default');



namespace App\Facade;

use Flawlol\Facade\Abstract\Facade;

class Arr extends
{
    protected static function getFacadeAccessor(): string
    {
        return ArrayHelper::class;
    }
}