} Facula\Unit\Route::setErrorHandler(function ($type) { $pageContent = ''; switch ($type) { case 'PATH_NOT_FOUND': case 'PATH_NO_OPERATOR': case 'PATH_NO_OPERATOR_SPECIFIED': default: if ($pageContent = Facula\Framework::core('template')->render('message.404')) { Facula\Framework::core('response')->setHeader('HTTP/1.1 404 Not Found'); Facula\Framework::core('response')->setContent($pageContent); Facula\Framework::core('response')->send(); } break; } return true; }); if (file_exists(Facula\Framework::PATH . DIRECTORY_SEPARATOR . '.htaccess')) { $path = array('Prefix' => '/', 'Path' => $_SERVER['QUERY_STRING']); } else { $path = array('Prefix' => '/?/', 'Path' => $_SERVER['QUERY_STRING']); } if (Facula\Unit\Route::setPath($path['Path'])) { Facula\Framework::core('template')->assign('RouteRoot', Facula\Framework::core('request')->getClientInfo('rootURL') . $path['Prefix']); Facula\Framework::core('template')->assign('AbsRouteRoot', Facula\Framework::core('request')->getClientInfo('absRootURL') . $path['Prefix']); Facula\Framework::core('template')->assign('RoutePath', Facula\Unit\Route::getPath()); } unset($path); Facula\Unit\Route::run(); return true; });
* GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Facula Framework. If not, see <http://www.gnu.org/licenses/>. * * @author Rain Lee <*****@*****.**> * @copyright 2015 Rain Lee * @package Facula * @version 0.1 alpha * @see https://github.com/raincious/facula FYI * */ /** * Check if example has disabled */ if (file_exists('..' . DIRECTORY_SEPARATOR . 'Lock')) { exit('Example disabled. Remove Lock file to enable.'); } /** * Require the framework */ require '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Bootstrap.php'; /** * Require the framework configuration file */ require 'privated' . DIRECTORY_SEPARATOR . 'Configurations' . DIRECTORY_SEPARATOR . 'Primary.php'; /** * Wake up the framework using the configuration */ Facula\Framework::run($cfg);
/** * Framework Demo: Route register for Demo API Page * * Facula Framework 2016 (C) Rain Lee * * Facula Framework is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, version 3. * * Facula Framework is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Facula Framework. If not, see <http://www.gnu.org/licenses/>. * * @author Rain Lee <*****@*****.**> * @copyright 2016 Rain Lee * @package Facula * @version 0.1 alpha * @see https://github.com/raincious/facula FYI * */ /** * Register the project execution function */ Facula\Framework::registerHook('route_init', 'homes-api', function () { Facula\Unit\Route::setup(array('/api/get_name' => array('MyProject\\Demo\\Controller\\API->displayGetName', array(), true))); return true; });
<?php if (file_exists('Lock')) { exit('Example disabled. Remove Lock file to enable.'); } require '..' . DIRECTORY_SEPARATOR . 'Bootstrap.php'; // date_default_timezone_set('UTC'); // mb_internal_encoding('UTF-8'); $configuration = array('AppName' => 'Facula Demo', 'AppVersion' => '0.0.0', 'Common' => array('CookiePrefix' => '_facula_'), 'UsingCore' => array('cache' => '\\Facula\\Core\\Cache'), 'Namespaces' => array(), 'Packages' => array(), 'Paths' => array(), 'Core' => array()); Facula\Framework::run($configuration); Facula\Framework::core('response')->setContent('Hello Word!'); Facula\Framework::core('response')->send(); // See http response header for changes