本文整理匯總了PHP中Phalcon\Mvc\Application::__construct方法的典型用法代碼示例。如果您正苦於以下問題:PHP Application::__construct方法的具體用法?PHP Application::__construct怎麽用?PHP Application::__construct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phalcon\Mvc\Application
的用法示例。
在下文中一共展示了Application::__construct方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* Instance construct
*/
public function __construct()
{
/**
* Create default DI
*/
$this->di = new DI\FactoryDefault();
$this->config = ZFactory::config();
if ($this->config->website->baseUri == '') {
if ($_SERVER['SERVER_PORT'] != '443') {
$this->config->website->baseUri = 'http://' . $_SERVER['HTTP_HOST'] . str_replace(['/public/index.php', '/index.php'], '', $_SERVER['SCRIPT_NAME']);
} else {
$this->config->website->baseUri = 'https://' . $_SERVER['HTTP_HOST'] . str_replace(['/public/index.php', '/index.php'], '', $_SERVER['SCRIPT_NAME']);
}
}
$this->di->set('config', $this->config);
/**
* @define bool DEBUG
*/
define('DEBUG', $this->config->debug);
/**
* @define string BASE_URI
*/
define('BASE_URI', $this->config->website->baseUri);
include ROOT_PATH . '/app/libraries/Core/Utilities/ZFunctions.php';
parent::__construct($this->di);
}
示例2: __construct
public function __construct($env, \Phalcon\DiInterface $di = null)
{
/**
* set environment
*/
self::$env = strtolower($env);
switch ($this::$env) {
case self::ENV_PRODUCTION:
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(0);
break;
case self::ENV_TESTING:
case self::ENV_DEVELOPMENT:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
break;
default:
throw new \Exception('Wrong application $env passed: ' . $env);
}
/**
* register di
*/
if (is_null($di)) {
$di = new \Phalcon\DI\FactoryDefault();
}
/**
* Read the configuration
*/
$config =& $this->config;
$config = new \Phalcon\Config(include ROOT_PATH . '/config/config.php');
$di->set('config', $config);
parent::__construct($di);
}
示例3: __construct
/**
* @param string $env
* @param array $configuration
* @param \Phalcon\DiInterface $di
* @throws \Exception
*/
public function __construct($env, array $configuration, \Phalcon\DiInterface $di = null)
{
$this->env = strtolower($env);
$this->configuration = $configuration;
switch ($this->env) {
case self::ENV_PRODUCTION:
case self::ENV_STAGING:
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(0);
break;
case self::ENV_TESTING:
case self::ENV_DEVELOPMENT:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
break;
default:
throw new \Exception('Wrong application $env passed: ' . $env);
}
if (is_null($di)) {
$di = new \Phalcon\DI\FactoryDefault();
}
parent::__construct($di);
}
示例4: __construct
/**
* Constructor.
*/
public function __construct()
{
/**
* Create default DI.
*/
$di = new DI\FactoryDefault();
/**
* Get config.
*/
$this->_config = Config::factory();
if (!$this->_config->installed) {
define('CHECK_REQUIREMENTS', true);
require_once PUBLIC_PATH . '/requirements.php';
}
/**
* Setup Registry.
*/
$registry = new Registry();
$registry->modules = array_merge([self::SYSTEM_DEFAULT_MODULE, 'user'], $this->_config->modules->toArray());
$registry->widgets = $this->_config->widgets->toArray();
$registry->directories = (object) ['engine' => ROOT_PATH . '/app/engine/', 'modules' => ROOT_PATH . '/app/modules/', 'plugins' => ROOT_PATH . '/app/plugins/', 'widgets' => ROOT_PATH . '/app/widgets/', 'libraries' => ROOT_PATH . '/app/libraries/'];
$di->set('registry', $registry);
// Store config in the DI container.
$di->setShared('config', $this->_config);
parent::__construct($di);
}
示例5: __construct
/**
* Application constructor.
* @param \Phalcon\DiInterface|null $dependencyInjector
* @param Config $config
*/
public function __construct(\Phalcon\DiInterface $dependencyInjector = null, Config $config)
{
parent::__construct($dependencyInjector);
$this->config = $config;
$this->_eventsManager = new Manager();
$dependencyInjector->set('config', $config);
$this->attachBootstrapEvents();
}
示例6: __construct
/**
* Bootstrap constructor - set the dependency Injector
*
* @package las
* @version 1.0
*
* @param \Phalcon\DiInterface $di
*/
public function __construct(\Phalcon\DiInterface $di)
{
$this->_di = $di;
$loaders = array('config', 'loader', 'timezone', 'i18n', 'db', 'filter', 'flash', 'crypt', 'auth', 'session', 'cookie', 'cache', 'url', 'router');
// Register services
foreach ($loaders as $service) {
$this->{$service}();
}
// Register modules
$this->registerModules(array('frontend' => array('className' => 'Las\\Frontend\\Module', 'path' => ROOT_PATH . '/app/frontend/Module.php'), 'admin' => array('className' => 'Las\\Backend\\Module', 'path' => ROOT_PATH . '/app/backend/Module.php'), 'doc' => array('className' => 'Las\\Doc\\Module', 'path' => ROOT_PATH . '/app/doc/Module.php')));
// Register the app itself as a service
$this->_di->set('app', $this);
// Set the dependency Injector
parent::__construct($this->_di);
}
示例7: __construct
/**
* Constructor
*/
public function __construct()
{
if (empty($this->_configPath)) {
$class = new \ReflectionClass($this);
throw new \Engine\Exception('Application has no config path: ' . $class->getFileName());
}
$loader = new \Phalcon\Loader();
$loader->registerNamespaces(['Engine' => ROOT_PATH . '/engine']);
$loader->register();
// create default di
$di = new \Phalcon\DI\FactoryDefault();
// get config
$this->_config = (include_once ROOT_PATH . $this->_configPath);
// Store config in the Di container
$di->setShared('config', $this->_config);
parent::__construct($di);
}
示例8: __construct
public function __construct(\Phalcon\DI $di = null)
{
if (!self::$_alreadyInit) {
self::$_alreadyInit = true;
self::$_instance = $this;
self::$_token = Tokenizer::randomToken();
$this->loader = new Autoloader(self::$_token);
new Constants();
$this->definePermissionGroups();
$this->di = $di == null ? new DependencyInjection() : $di;
$this->_registerServices();
parent::__construct($this->di);
$this->_registerDefaultModule();
$this->_registerModules();
$this->_registerListeners();
$this->debug = new \Phalcon\Debug();
} else {
self::throwException(null, 100);
}
}
示例9: __construct
/**
* Constructor.
*/
public function __construct()
{
/**
* Create default DI.
*/
$di = new DI\FactoryDefault();
/**
* Get config.
*/
$this->_config = Config::factory();
/**
* Adding modules to registry to load.
* Module namespace - directory will be load from here.
*/
$registry = new PhRegistry();
$registry->modules = array_merge([self::SYSTEM_DEFAULT_MODULE], $this->_config->modules->toArray());
$registry->directories = (object) ['engine' => ROOT_PATH . '/app/engine/', 'modules' => ROOT_PATH . '/app/modules/'];
$di->set('registry', $registry);
/**
* Store config in the DI container.
*/
$di->setShared('config', $this->_config);
parent::__construct($di);
}
示例10: __construct
/**
* @param DiInterface $dependencyInjector
*/
public function __construct(DiInterface $dependencyInjector)
{
parent::__construct($dependencyInjector);
$this->useImplicitView(false);
}
示例11: __construct
public function __construct(Bootstrap $bootstrap)
{
parent::__construct($bootstrap->getDI());
$this->bootstrap = $bootstrap;
$this->config = $bootstrap->getConfig();
}
示例12: __construct
/**
* Creates an extended Phalcon Application that additionally
* loads environment variables and bootstraps important handlers.
*
* @param DependencyInjector|null $dependencyInjector
*/
public function __construct($rootDir, $configFile, DependencyInjector $DI)
{
parent::__construct($DI);
$this->setRootDirectory($rootDir);
$this->setConfigFile($configFile);
}
示例13: __construct
/**
* Class constructor registers autoloading and error
* handler.
*
* @param mixed $dependencyInjector
* @return \Phalcon\Error\Application
*/
public function __construct(DiInterface $dependencyInjector = null)
{
$this->registerAutoloaders();
ErrorHandler::register();
parent::__construct($dependencyInjector);
}
示例14: __construct
public function __construct($di)
{
parent::__construct($di);
$this->config = ApplicationConfig::getConfig();
self::$app = $this;
}
示例15: __construct
public function __construct($projectPath, $environment = Application::ENVIRONMENT_DEV)
{
$this->application = new Application($this, $projectPath, $environment);
parent::__construct();
}