예제 #1
0
 public static function readAllRoutes()
 {
     $filePaths = \SoftUni\Core\Annotations::getDirContents($_SERVER['DOCUMENT_ROOT']);
     $routeConfigFilePaths = self::getAllRouteConfigFilePaths($filePaths);
     self::$routes = [];
     foreach ($routeConfigFilePaths as $routeConfigFilePath) {
         //var_dump($routeConfigFilePath);
         $routePath = array_pop($routeConfigFilePath);
         //var_dump($routePath);
         require_once $routePath;
         if (preg_match('/Areas(.*?)Config/i', $routePath, $match)) {
             $area = str_replace('\\', '', $match[1]);
             $area = str_replace('/', '', $area);
             self::$routes['Area'] = array($area => $routes);
         }
         if (preg_match('#(Application)[\\\\/]Config#i', $routePath, $match)) {
             self::$routes['Application'] = $routes;
         }
         if (preg_match('#(Framework)[\\\\/]Config#i', $routePath, $match)) {
             self::$routes['Framework'] = $routes;
         }
     }
     $routesFromAnnotations = \SoftUni\Core\Annotations::$allAnnotations['Routes'];
     self::$routes['Annotations'] = $routesFromAnnotations;
 }
 public static function init()
 {
     spl_autoload_register(function ($class) {
         // remove vendor from the class path
         $position = stripos($class, "\\");
         $class = substr($class, $position);
         $class = str_replace('\\', '\\\\', $class);
         // find proper file for this class
         $dirs = Annotations::getDirContents($_SERVER['DOCUMENT_ROOT']);
         $classFile = array_filter($dirs, function ($dir) use($class) {
             $pattern = '/' . $class . '/';
             if (preg_match($pattern, $dir)) {
                 return $dir;
             }
         });
         // require the file if it is found
         $firstMatchedFile = array_pop($classFile);
         if (isset($firstMatchedFile)) {
             require_once $firstMatchedFile;
         }
     });
 }
예제 #3
0
<?php

session_start();
include_once 'Framework' . DIRECTORY_SEPARATOR . 'Autoloader.php';
include_once 'Framework' . DIRECTORY_SEPARATOR . 'Application.php';
include_once 'Framework' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'Annotations.php';
\SoftUni\Autoloader::init();
\SoftUni\Core\Annotations::getAnnotations();
//\SoftUni\Core\Database::setInstance(
//    \SoftUni\Config\DatabaseConfig::DB_INSTANCE,
//    \SoftUni\Config\DatabaseConfig::DB_DRIVER,
//    \SoftUni\Config\DatabaseConfig::DB_USER,
//    \SoftUni\Config\DatabaseConfig::DB_PASS,
//    \SoftUni\Config\DatabaseConfig::DB_NAME,
//    \SoftUni\Config\DatabaseConfig::DB_HOST
//);
$app = new \SoftUni\Application();
$app->start();
?>