/** * Get or create the singleton alias loader instance. * * @param array $aliases * @return AliasLoader */ public static function getInstance(array $aliases = []) { if (is_null(static::$instance)) { return static::$instance = new static($aliases); } $aliases = array_merge(static::$instance->getAliases(), $aliases); static::$instance->setAliases($aliases); return static::$instance; }
/** * Register the service provider. * * @return void */ public function register() { // Use the provided config as default. $this->mergeConfigFrom(__DIR__ . '/../config/intercom.php', 'intercom'); $this->app->singleton('intercom', function ($app) { $appID = $app['config']->get('intercom.app_id'); $apiKey = $app['config']->get('intercom.api_key'); $intercom = new IntercomClient($appID, $apiKey); return new IntercomApi($intercom); }); $this->app->booting(function () { $loader = AliasLoader::getInstance(); $loader->alias('Intercom', Intercom::class); }); }
define('STARTTIME', microtime(1)); define('BASEDIR', dirname(__DIR__)); define('APP', BASEDIR . '/app'); define('HOME', BASEDIR . '/public'); define('STORAGE', APP . '/storage'); define('PCLZIP_TEMPORARY_DIR', STORAGE . '/temp/'); define('VERSION', '5.0.1'); /** * Автозагрузка классов */ require_once BASEDIR . '/vendor/autoload.php'; /** * Регистрация классов */ $aliases = ['Blade' => 'Philo\\Blade\\Blade', 'Carbon' => 'Carbon\\Carbon', 'SimpleImage' => 'abeautifulsite\\SimpleImage', 'Utf8' => 'Patchwork\\Utf8', 'Curl' => 'Curl\\Curl']; AliasLoader::getInstance($aliases)->register(); if (!env('APP_ENV')) { $dotenv = new Dotenv\Dotenv(BASEDIR); $dotenv->load(); } if (env('APP_DEBUG')) { $whoops = new Whoops\Run(); $whoops->pushHandler(new Whoops\Handler\PrettyPageHandler()); $whoops->pushHandler(function ($exception, $inspector, $run) { $_SERVER = array_except($_SERVER, array_keys($_ENV)); $_ENV = []; }); $whoops->register(); } /** * ActiveRecord initialize
public function __construct() { spl_autoload_register(array($this, 'loader')); $aliaser = new AliasLoader(); $aliaser->register(); }