Config loader for Phalcon PHP framework 1.0
<?php
defined('APPLICATION_PATH') ||
define('APPLICATION_PATH', '/app');
defined('APPLICATION_ENV') ||
define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development');
include_once(APPLICATION_PATH . '/PhalconServiceLoader.php');
$app = \PhalconServiceLoader::createWebApp(APPLICATION_PATH . '/config.php');
echo $app->handle()->getContent();
###config.php
<?php
return new \Phalcon\Config(array(
'services' => array(
'loader' => array(
// ...
),
'logger' => array(
// ...
'shared_instance' => true,
),
),
));
#####Reserved
- "services" - services definitions
- "shared_instances" - register the service as "always shared"
'services' => array(
...
'loader' => array(
'className' => '\Phalcon\Loader',
'calls' => array(
array('method' => 'registerDirs', 'arguments' => array(
array('type' => 'parameter', 'value' => array(
'controllers' => APPLICATION_PATH . '/controllers/',
'models' => APPLICATION_PATH . '/models/',
'library' => APPLICATION_PATH . '/library/',
))
)),
array('method' => 'register'),
),
),
...
),
'services' => array(
...
'environment' => function(\Phalcon\Mvc\Application $app) {
error_reporting(0);
ini_set('log_errors', 1);
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
set_exception_handler(array($app, 'handleException'));
set_error_handler(array($app, 'handleError'), error_reporting());
},
...
),
'services' => array(
...
'logger' => array(
'className' => '\Phalcon\Logger\Adapter\Syslog',
'arguments' => array(
array('type' => 'parameter', 'value' => null),
),
'shared_instance' => true,
),
...
),
'services' => array(
...
'cache' => array(
'className' => '\Phalcon\Cache\Backend\Memcache',
'arguments' => array(
array(
'type' => 'instance',
'className' => '\Phalcon\Cache\Frontend\Data',
'arguments' => array('lifetime' => 60)
),
),
'shared_instance' => true,
),
...
),
'services' => array(
...
'session' => array(
'className' => '\Phalcon\Session\Adapter\Files',
'calls' => array(array('method' => 'start')),
'shared_instance' => true,
),
...
),
'services' => array(
...
'url' => array(
'className' => '\Phalcon\Mvc\Url',
'calls' => array(
array('method' => 'setBaseUri', 'arguments' => array(
array('type' => 'parameter', 'value' => '/'),
)),
),
'shared_instance' => true,
),
...
),
'services' => array(
...
'view' => array(
'className' => '\Phalcon\Mvc\View',
'calls' => array(
array('method' => 'setViewsDir', 'arguments' => array(
array('type' => 'parameter', 'value' => APPLICATION_PATH . '/views/'),
)),
),
'shared_instance' => true,
),
...
),