function main() { // error_reporting(E_ALL); date_default_timezone_set('UTC'); require '../vendor/autoload.php'; $app = new Core\Application(require '../config/config.php'); $app->run(); }
<?php define('APPLICATION_PATH', __DIR__ . '/application/'); define('LIBRARY_PATH', __DIR__ . '/library/'); define('PUBLIC_PATH', __DIR__ . '/public/'); define('FRONTEND_PATH', APPLICATION_PATH . 'modules/frontend/'); define('BACKEND_PATH', APPLICATION_PATH . 'modules/backend/'); // Get autoload Zend/Symfony Standard PS-4 require_once LIBRARY_PATH . 'Core/Autoload.php'; // Autoload Instance $autoload = new Psr4AutoloaderClass(); // Load Needed Namespaces for the application $autoload->addNamespace('Core', LIBRARY_PATH . 'Core')->addNamespace('Application', APPLICATION_PATH)->addNamespace('Backend', BACKEND_PATH)->addNamespace('Frontend', FRONTEND_PATH); $autoload->register(); // estaria bueno definir las routes aca y el acces list? // onda.. Access list y se lo inyecto a la aplicacion. //$acl = new Acl(); //$acl->addRole(); // lo mismo con las routes.. // las routes es tambien para forwardear un 404, un 500 etc.. // Create the Application via Namespace.. $api = new Core\Application(); $api->init()->start();
<?php session_start(); define("ROOT_DIR", __DIR__); include "autoload.php"; include "vendor/autoload.php"; include "src/Core/Exceptions.php"; $router = new \Core\Router(); $router->route(); $app = new \Core\Application(); $app->run($router->getController(), $router->getAction());
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/../config/path.php'; require_once URL . '/Core/Loader.php'; $loader = new Loader(); try { $app = new Core\Application(); $app->run(); } catch (InvalidArgumentException $e) { include URL . "src/error.php"; exit; } catch (Exception $e) { Core\Service::get('log')->error($e->getMessage() . " & Code " . $e->getCode() . $e->getFile() . $e->getLine()); include URL . "src/error.php"; exit; }
<?php if (!defined('BASEDIR')) { exit('File not found'); } // 加载自动加载类中 composer方式 并注册到系统中 $loader = (include BASEDIR . '/vendor/autoload.php'); spl_autoload_register(array($loader, 'loadClass')); // 初始化框架入口 容器 $app = new \Core\Application(); // 注册服务到框架中,全局都可以调用 调用时候 $container->make(service) $app->alias('App\\Service\\Task\\TaskService', 'taskServer'); $app->alias('App\\Service\\Message\\MessageService', 'messageServer'); $app->alias('App\\Service\\User\\UserService', 'userServer'); $app->alias('App\\Service\\UserGroup\\UserGroupService', 'userGroupServer'); $app->alias('App\\Service\\System\\SystemService', 'systemServer'); $app->alias('App\\Service\\Lottery\\LotteryService', 'lotteryServer'); // 加载项目所有路由配置 include 'Config/route.php'; return $app;
/** * Running application */ public static function run() { $application = new \Core\Application(); $application->dispatch(); }
public function testSetState() { $stateData = array('login_key' => 'login_value', 'book_key' => 'book_value', 'browse_key' => 'browse_value', 'det_key' => 'det_value', 'det_ret_key' => 'det_ret_value', 'emp_key' => 'emp_value', 'empl_key' => 'empl_value'); $sessionStub = $this->getMockBuilder('\\Core\\Session')->getMock(); $app = new \Core\Application('', $sessionStub); $app->setStateLogin(array('login_key' => 'login_value')); $this->assertEquals(\Core\Application::STATE_LOGIN, $app->getState()); $app->setStateBook(array('book_key' => 'book_value')); $this->assertEquals(\Core\Application::STATE_BOOK, $app->getState()); $app->setStateBrowse(array('browse_key' => 'browse_value')); $this->assertEquals(\Core\Application::STATE_BROWSE, $app->getState()); $app->setStateDetails(array('det_key' => 'det_value')); $this->assertEquals(\Core\Application::STATE_DETAILS, $app->getState()); $app->setStateDetailsReturn(array('det_ret_key' => 'det_ret_value')); $this->assertEquals(\Core\Application::STATE_DETAILS_RETURN, $app->getState()); $app->setStateEmployee(array('emp_key' => 'emp_value')); $this->assertEquals(\Core\Application::STATE_EMPLOYEE, $app->getState()); $app->setStateEmployeeList(array('empl_key' => 'empl_value')); $this->assertEquals(\Core\Application::STATE_EMPLOYEE_LIST, $app->getState()); $app->setStateRedirect('http'); $this->assertEquals(\Core\Application::STATE_REDIRECT, $app->getState()); $this->assertEquals('http', $app->getRedirectUrl()); $this->assertArraySubset($stateData, $app->getAppData()); }
*/ define('ROOT_PATH', dirname(dirname(__FILE__))); define('APP_PATH', ROOT_PATH . '/app'); define('PUBLIC_PATH', ROOT_PATH . '/public'); define('CACHE_PATH', ROOT_PATH . '/cache'); define('VIEW_PATH', ROOT_PATH . '/view'); define('APP_ENV', getenv('APP_ENV') ? getenv('APP_ENV') : 'development'); /** * set Error display */ switch (APP_ENV) { case 'development': case 'testing': ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(-1); break; case 'production': default: ini_set('display_errors', 0); ini_set('display_startup_errors', 0); error_reporting(0); break; } /** * Register loader */ require APP_PATH . "/../vendor/autoload.php"; // composer loader $application = new Core\Application(APP_ENV); $application->bootstrap()->run();
<?php if (!defined('BASEDIR')) { exit('File not found'); } // 加载自动加载类中 composer方式 并注册到系统中 $loader = (include BASEDIR . '/vendor/autoload.php'); spl_autoload_register(array($loader, 'loadClass')); // 初始化框架入口 容器 $app = new \Core\Application(); // 注册服务到框架中,全局都可以调用 调用时候 $container->make(service) $app->alias('App\\Service\\Task\\TaskService', 'taskServer'); $app->alias('App\\Service\\Message\\MessageService', 'messageServer'); // 加载项目所有路由配置 include 'Config/route.php'; return $app;