Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use Phalcon\Loader;
- use Phalcon\Mvc\View;
- use Phalcon\Mvc\Url as UrlProvider;
- use Phalcon\Mvc\Application;
- use Phalcon\DI\FactoryDefault;
- use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
- use Phalcon\Config\Adapter\Ini as ConfigIni;
- use Phalcon\Session\Adapter\Files as Session;
- try
- {
- $config = new ConfigIni("../backend/configs/config.ini");
- $loader = new Loader();
- $loader->registerDirs(array(
- $config->app->controllers,
- $config->app->models,
- $config->app->library
- ))->register();
- $di = new FactoryDefault();
- // Setup the database service
- $di->set('db', function() use ($config){
- return new DbAdapter(array(
- "host" => $config->database->host,
- "username" => $config->database->username,
- "password" => $config->database->password,
- "dbname" => $config->database->database
- ));
- });
- $di->set('session', function()
- {
- $session = new Session();
- $session->start();
- return $session;
- });
- $di->set("view", function() use ($config)
- {
- $view = new View();
- $view->setViewsDir($config->app->views);
- $view->registerEngines(array(
- '.volt' => 'Phalcon\Mvc\View\Engine\Volt',
- '.phtml' => 'Phalcon\Mvc\View\Engine\Volt'
- ));
- return $view;
- });
- // Setup a base URI so that all generated URIs include the "tutorial" folder
- $di->set('url', function() use ($config){
- $url = new UrlProvider();
- $url->setBaseUri($config->app->basedir);
- return $url;
- });
- $di->set('elements', function() use($config){
- $element = new Elements();
- $element->SetSiteName( $config->web->sitename );
- return $element;
- });
- // Handle the request
- $application = new Application($di);
- $application->setDI($di);
- echo $application->handle()->getContent();
- }
- catch(\Exception $e)
- {
- echo "Bootstrap error -> " . $e->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement