function view($templateFile, $args = []) { $app = App::getApp(); $template = $app->twig->loadTemplate($templateFile); return $template->render($args); }
public function __construct() { $this->app = App::getApp(); }
public function test_singleton() { $this->assertInstanceOf('\\Tunnel\\Core\\Application', $this->app); $app2 = App::getApp(); $this->assertEquals($app2, $this->app); }
<?php use Tunnel\Core\Application as App; use Tunnel\Router\Router; use Tunnel\View\View; use Tunnel\Helpers\UrlHelper; use Carbon\Carbon; // Define paths define('ROOT_PATH', realpath('../')); define('APP_PATH', ROOT_PATH . '/app'); define('WEBROOT_PATH', ROOT_PATH . '/public'); define('VENDOR_PATH', ROOT_PATH . '/vendor'); define('FRAMEWORK_PATH', ROOT_PATH . '/framework'); // Autoload stuff & get config var require_once VENDOR_PATH . '/autoload.php'; require_once FRAMEWORK_PATH . '/src/Globals.php'; $config = (require_once APP_PATH . '/config.php'); // Create our application object $app = App::getApp(); $app->setConfig($config); $app->boot(); /* Register our modules */ $app->bind('router', new Router('404.html')); $app->bind('view', new View()); $app->bind('url', new UrlHelper()); $app->bind('date', new Carbon());