本文整理汇总了PHP中Slim\App::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP App::__construct方法的具体用法?PHP App::__construct怎么用?PHP App::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slim\App
的用法示例。
在下文中一共展示了App::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$containerBuilder = new ContainerBuilder();
$containerBuilder->addDefinitions(__DIR__ . '/config.php');
$container = $containerBuilder->build();
parent::__construct($container);
}
示例2: __construct
/**
* Shiniwork constructor.
*
* @param array $settings
*/
public function __construct(array $settings = [])
{
session_start();
$container = new Settings($settings);
parent::__construct($container);
$this->registerView()->registerDatabase()->registerMailer()->registerJWT()->addJWTMiddleware();
}
示例3: __construct
/**
*
* @param array $routes
* @param unknown $options
*/
public function __construct(array $routes, $options = null)
{
parent::__construct($options);
$this->container = $this->getContainer();
$this->_routes = $routes;
$this->resolve();
}
示例4: __construct
/**
* {@inheritdoc}
*/
public function __construct(Container $container = null)
{
$container = $container ?: new Container();
$container->delegate(new ReflectionContainer());
$container->addServiceProvider(new SlimServiceProvider());
parent::__construct($container);
}
示例5: __construct
/**
* App constructor.
*
* @param $basePath
*/
public function __construct($basePath)
{
$this->setBasePath($basePath);
$this->init();
$container = new SlimContainer();
parent::__construct($container);
self::$instance = $this;
}
示例6: __construct
/**
* @param ContainerInterface|array $container
*/
public function __construct($container = [])
{
parent::__construct($container);
$this->getContainer()['app'] = function () {
return $this;
};
$this->setupEnvData();
$this->loadRoutes();
$this->setupNotFound();
}
示例7: __construct
/**
* {@inheritdoc}
*/
public function __construct($userSettings = [])
{
parent::__construct($userSettings);
if ($userSettings['debug']) {
$this->debug = $userSettings['debug'];
}
$this->config = Config::getInstance();
$this->registerHandlers();
$this->registerServices();
}
示例8: __construct
/**
* Create a new application.
*
* @param string $basePath
*/
public function __construct($basePath)
{
if (is_null($basePath)) {
throw new \InvalidArgumentException("The base path has not been set.");
}
parent::__construct();
// Make the container instance used by this application
// globally available.
Container::setInstance($this->getContainer());
$this->setBasePath($basePath);
$this->bootstrap();
}
示例9: __construct
/**
* @param ContainerInterface|array $container
*/
public function __construct($container = [])
{
parent::__construct($container);
$this->getContainer()['app'] = function () {
return $this;
};
$this->setupServices();
$this->setupEnvData();
$this->loadRoutes();
$this->setupNotFound();
$this->setupErrorHandler();
Model::setApp($this);
}
示例10: __construct
public function __construct($container = null)
{
parent::__construct($container);
$this->loadDI();
$this->loadPlugins();
}
示例11: __construct
/**
* @param array|\Interop\Container\ContainerInterface $config
* @param $debug
*/
public function __construct($config, $debug)
{
$config['displayErrorDetails'] = $debug;
parent::__construct(['settings' => $config]);
}
示例12: array
function __construct($settings)
{
parent::__construct($settings);
$more = array();
self::$instance = $this;
}
示例13: __construct
public function __construct($container = [])
{
parent::__construct($container);
$this->setUpRoutes();
$this->setupRenderer();
}
示例14: __construct
/**
* Constructor
*
* @param array|ContainerInterface $container Instancia de Container o array de configuración. Default: []
*/
public function __construct($container = [])
{
parent::__construct($container);
$this->registerDafaultServicesProvider();
$this->registerServiceProviders();
}
示例15: __construct
/**
* @internal
*/
public function __construct($userSettings = null)
{
$configDir = '.';
// Пользовательские настройки
// --------------------------
if (!is_array($userSettings)) {
$userSettings = array('file' => $userSettings);
}
if ($file = @$userSettings['file']) {
unset($userSettings['file']);
if (file_exists($file)) {
$configDir = dirname($file);
$settings = Utils::loadConfig($file);
Log::debug("Configuration load: " . realpath($file));
unset($file);
$userSettings = array_merge($userSettings, $settings);
}
}
$userSettings = array_merge($this->defaultsSettings, $userSettings);
if ($p = $userSettings['templates.path']) {
if (substr($p, 0, 1) !== '/') {
$userSettings['templates.path'] = SYSPATH . '/' . $p;
}
}
// if (is_array($userSettings['import'])) {
// $import = $userSettings['import'];
// foreach ($import as $file) {
// $file = $configDir . '/' . $file;
// $settings = Utils::loadConfig($file);
// if ($settings) {
// $defaultSettings = array_merge($defaultSettings, $settings);
// Log::debug("Configuration import",
// array(realpath($file)));
// }
// }
// }
parent::__construct((array) $userSettings);
$app =& $this;
// Если Internet Explorer, то шлем на хуй
/*
if (preg_match('/(rv:11.0|MSIE)/i', $_SERVER['HTTP_USER_AGENT'])) {
$app->log->warning('Bad Browser ', array('HTTP_USER_AGENT'=>$_SERVER['HTTP_USER_AGENT']));
$app->redirect( "http://fobia.github.io/docs/badbrowser.html" );
exit();
}
*/
// // Автоматическая загрузка секций конфигурации
// ----------------------------------------------
$autoload = $this['settings']['app.autoload'];
if ($autoload) {
$this['settings']['app'] = new \Pimple();
$this['settings']['app']['autoload'] = $autoload;
if (is_array($autoload)) {
foreach (@$autoload as $cfg => $file) {
$this['settings']['app'][$cfg] = function ($c) use($cfg, $file, $configDir) {
Log::debug(">> autoload config", array($cfg, $file));
if (!file_exists($configDir . "/{$file}")) {
trigger_error("Нет автозагрузочной секции конфигурации '{$cfg}'" . "/{$file}", E_USER_ERROR);
return;
}
return Utils::loadConfig($file);
};
}
}
}
unset($autoload, $cfg, $file);
// Session
// session.gc_maxlifetime = 1440
// ;setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
// ------------------
$this['session'] = function ($c) {
$sid = null;
if ($c['settings']['session.cookie'] && @$_COOKIE['SID']) {
$sid = $_COOKIE['SID'];
session_id($sid);
}
$session = new \Slim\Session($c['settings']['session.handler']);
@$session->start();
if ($c['settings']['session.encrypt'] === true) {
$session->decrypt($c['crypt']);
}
if ($sid === null) {
$sid = session_id();
if ($c['settings']['session.cookie']) {
@$c->setCookie('SID', $sid, time() + 1440);
Log::debug('Session save cookie');
}
}
Log::debug('Session start', array($sid));
return $session;
};
// View
// ------------------
$this['view'] = function ($c) {
$view = $c['settings']['view'];
if ($view instanceof \Slim\Interfaces\ViewInterface !== false) {
return $view;
//.........这里部分代码省略.........