1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the Ocrend Framewok 3 package. |
||
5 | * |
||
6 | * (c) Ocrend Software <[email protected]> |
||
7 | * @author Brayan Narváez <[email protected]> |
||
8 | * |
||
9 | * For the full copyright and license information, please view the LICENSE |
||
10 | * file that was distributed with this source code. |
||
11 | */ |
||
12 | |||
13 | use Symfony\Component\HttpFoundation\Session\Session; |
||
14 | use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; |
||
15 | use Symfony\Component\HttpFoundation\Request; |
||
16 | use Symfony\Component\Debug\ExceptionHandler; |
||
17 | use Symfony\Component\Debug\ErrorHandler; |
||
18 | use Symfony\Component\Yaml\Yaml; |
||
19 | use Symfony\Component\Yaml\Exception\ParseException; |
||
20 | use Ocrend\Kernel\Cookies\Cookies; |
||
21 | |||
22 | # Cargadores iniciales |
||
23 | require ___ROOT___ . 'Ocrend/vendor/autoload.php'; |
||
24 | require ___ROOT___ . 'Ocrend/autoload.php'; |
||
25 | |||
26 | # Manejador de excepciones |
||
27 | ErrorHandler::register(); |
||
28 | ExceptionHandler::register(); |
||
29 | |||
30 | # Mínima versión, alerta |
||
31 | if (version_compare(phpversion(), '7.0.0', '<')) { |
||
32 | throw new \RuntimeException('La versión actual de PHP es ' . phpversion() . ' y como mínimo se require la versión 7.0.0'); |
||
33 | } |
||
34 | |||
35 | # Verificar usabilidad de twig |
||
36 | $__TWIG_CACHE_PATH = ___ROOT___ . 'app/templates/.compiled/'; |
||
37 | $__TWIG_READABLE_AND_WRITABLE = !is_readable($__TWIG_CACHE_PATH) || !is_writable($__TWIG_CACHE_PATH); |
||
38 | if ($__TWIG_READABLE_AND_WRITABLE) { |
||
39 | |||
40 | # Intentar solucionarlo |
||
41 | if(!is_dir($__TWIG_CACHE_PATH)) { |
||
42 | mkdir($__TWIG_CACHE_PATH, 0644, true); |
||
43 | } else { |
||
44 | chmod($__TWIG_CACHE_PATH, 0644); |
||
45 | } |
||
46 | |||
47 | # Revisar la lecutra para twig |
||
48 | if($__TWIG_READABLE_AND_WRITABLE) { |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
49 | throw new \RuntimeException('Debe conceder permisos de escritura y lectura a la ruta '. $__TWIG_CACHE_PATH .' ó crearla si no existe.'); |
||
50 | } |
||
51 | } |
||
52 | |||
53 | # Obtener la data informativa |
||
54 | $config = Yaml::parse(file_get_contents(___ROOT___ . 'Ocrend/Kernel/Config/Ocrend.ini.yml')); |
||
55 | |||
56 | # Cargador de sesiones |
||
57 | $session = new Session(new NativeSessionStorage( |
||
58 | array( |
||
59 | 'cookie_lifetime' => $config['sessions']['lifetime'] |
||
60 | ) |
||
61 | )); |
||
62 | $session->start(); |
||
63 | |||
64 | # Cargador de cookies |
||
65 | $cookie = new Cookies; |
||
66 | $cookie->reviveSessions(); |
||
67 | |||
68 | # Peticiones HTTP |
||
69 | $http = Request::createFromGlobals(); |
||
70 | |||
71 | # Define el timezone actual |
||
72 | date_default_timezone_set($config['build']['timezone']); |