Example #1
0
 * @license     http://opensource.org/licenses/bsd-license.php
 * @link        http://titon.io
 */
use Titon\Cache\Cache;
use Titon\Common\Registry;
use Titon\Controller\Controller\ErrorController;
use Titon\Db\Database;
use Titon\Environment\Environment;
use Titon\G11n\G11n;
use Titon\Mvc\Application;
use Titon\Mvc\View;
use Titon\View\Helper\BlockHelper;
use Titon\View\Helper\Html\AssetHelper;
use Titon\View\Helper\Html\HtmlHelper;
use Titon\View\View\Engine\TemplateEngine;
$app = Application::getInstance();
/**
 * --------------------------------------------------------------
 *  Component Mapping
 * --------------------------------------------------------------
 *
 * Components are objects that should be accessed globally
 * through the application layer. These components are the
 * gears that drive the application.
 *
 * All components can be accessed through their key by
 * calling get() on the application object.
 */
$app->set('env', new Environment(['bootstrapPath' => RESOURCES_DIR . 'environments/']))->set('cache', new Cache())->set('g11n', new G11n())->set('db', new Database());
/**
 * --------------------------------------------------------------
Example #2
0
File: index.php Project: titon/app
 * to composer in case we need to modify the loader.
 */
$composer = (require_once VENDOR_DIR . 'autoload.php');
Registry::set($composer, 'titon.composer');
/**
 * --------------------------------------------------------------
 *  Application Bootstrap
 * --------------------------------------------------------------
 *
 * Now it's time to start the application. We can do this by
 * instantiating a new Application object. We'll use a multiton
 * so that we can access the Application object statically.
 * Lastly, pass in a Request and Response object as constructor
 * parameters, which will be passed down to child classes.
 */
$app = Application::getInstance('default', [new Request(), new Response()]);
/**
 * Bootstrap the application with configuration.
 * Order here is extremely critical, do not change!
 */
foreach (['setup', 'registry', 'environments', 'cache', 'locales', 'database', 'modules', 'routes'] as $config) {
    $path = sprintf(RESOURCES_DIR . 'bootstrap/%s.php', $config);
    if (file_exists($path)) {
        require_once $path;
    }
}
/**
 * Now we can run the application. We want to pass the webroot
 * so that symlinking of assets work properly.
 */
$app->run(WEB_DIR);