Example #1
0
<?php

namespace Application;

use Nerd\Design\Architectural\MVC\Controller;
use Nerd\Design\Architectural\MVC\View;
use Nerd\Input;
return ['controller.setup' => function (Controller $controller) {
    $session = Application::instance()->session;
    if (!Input::protect($session->get('application.csrf'))) {
        throw new \Nerd\Http\Exception(403);
    }
    $controller->application = Application::instance();
    $controller->session = $session;
    $controller->flash = $session->flash;
    $controller->response = Application::instance()->response;
    $controller->template = new View('template');
}];
Example #2
0
 * Get and register the Composer autoloader as a secondary loader.
 */
require LIBRARY_PATH . '/../vendor/autoload.php';
/**
 * Here you could do some magic for multiple applications by dynamically switching
 * the application namespace for this request. To create another application you
 * would simply create another subfolder in LIBRARY_PATH with its own Application
 * class...
 */
define('APPLICATION_NS', 'application');
define('STORAGE_PATH', LIBRARY_PATH . DS . 'application/storage');
/**
 * Setup the current environment
 */
$env = Environment::$active;
//die(var_dump($env));
/**
 * The following items need to be done for every request, but since they require
 * APPLICATION_NS to be defined, the must be done in the application bootstrap file.
 *
 *   [!!] Edit at your own risk
 *
 */
error_reporting(Config::get('error.reporting'));
ini_set('display_errors', Config::get('error.display', true) ? 'On' : 'Off');
date_default_timezone_set(Config::get('application.timezone', 'UTC'));
\Nerd\Str::$mbString and mb_internal_encoding(Config::get('application.encoding', 'UTF-8'));
$application = Application::instance();
$application->triggerEvent('application.startup');
$application->response->send(true);
$application->triggerEvent('application.shutdown');
Example #3
0
<?php

namespace Application;

use Nerd\Design\Architectural\MVC\View;
return ['view.setup' => function () {
    View::set('application', Application::instance());
    View::set('flash', Application::instance()->session->flash);
}, 'view.render' => function (View $view) {
}];