@@ -5,12 +5,12 @@ |
||
5 | 5 | use Phpmig\Adapter; |
6 | 6 | use Illuminate\Database\Capsule\Manager as Capsule; |
7 | 7 | include 'settings.php'; |
8 | -$capsule = new Capsule; |
|
8 | +$capsule = new Capsule; |
|
9 | 9 | $capsule->addConnection($config['databases']['db']); |
10 | 10 | $capsule->setAsGlobal(); |
11 | 11 | $capsule->bootEloquent(); |
12 | 12 | $container = new ArrayObject(); |
13 | 13 | $container['phpmig.adapter'] = new Adapter\Illuminate\Database($capsule, 'migrations'); |
14 | -$container['phpmig.migrations_path'] = 'database/migrations'; |
|
14 | +$container['phpmig.migrations_path'] = 'database/migrations'; |
|
15 | 15 | $container['phpmig.migrations_template_path'] = 'core/resources/templates/create_migration.txt'; |
16 | 16 | return $container; |
17 | 17 | \ No newline at end of file |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -if($config['settings']['app']['debug'] && $config['settings']['tracy']['active']) { |
|
2 | +if ($config['settings']['app']['debug'] && $config['settings']['tracy']['active']) { |
|
3 | 3 | $app->add(new RunTracy\Middlewares\TracyMiddleware($app)); |
4 | 4 | } |
5 | 5 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | $container = $app->getContainer(); |
5 | 5 | |
6 | 6 | /* database connection */ |
7 | -$container['db'] = function ($container) { |
|
7 | +$container['db'] = function($container) { |
|
8 | 8 | $db = $container['settings']['databases']['db']; |
9 | 9 | $pdo = new PDO("mysql:host=" . $db['host'] . ";dbname=" . $db['database'], |
10 | 10 | $db['username'], $db['password']); |
@@ -52,18 +52,18 @@ discard block |
||
52 | 52 | // |
53 | 53 | |
54 | 54 | |
55 | -$container['generalErrorHandler'] = function ($container) { |
|
55 | +$container['generalErrorHandler'] = function($container) { |
|
56 | 56 | return new \Core\Handlers\GeneralErrorHandler($container); |
57 | 57 | }; |
58 | 58 | |
59 | 59 | |
60 | 60 | // Service factory for the ORM |
61 | -$container['validator'] = function () { |
|
61 | +$container['validator'] = function() { |
|
62 | 62 | return new App\Validation\Validator(); |
63 | 63 | }; |
64 | 64 | |
65 | 65 | |
66 | -$container['eloquent'] = function ($container) { |
|
66 | +$container['eloquent'] = function($container) { |
|
67 | 67 | $db = $container['settings']['databases']['db']; |
68 | 68 | |
69 | 69 | $capsule = new \Illuminate\Database\Capsule\Manager; |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | |
85 | 85 | // monolog |
86 | -$container['logger'] = function ($container) { |
|
86 | +$container['logger'] = function($container) { |
|
87 | 87 | $settings = $container->get('settings')['app']['logger']; |
88 | 88 | $logger = new Monolog\Logger($settings['name']); |
89 | 89 | $logger->pushProcessor(new Monolog\Processor\UidProcessor()); |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | |
94 | 94 | |
95 | 95 | // not found handler |
96 | -$container['notFoundHandler'] = function ($container) { |
|
97 | - return function (\Slim\Http\Request $request, \Slim\Http\Response $response) use ($container) { |
|
96 | +$container['notFoundHandler'] = function($container) { |
|
97 | + return function(\Slim\Http\Request $request, \Slim\Http\Response $response) use ($container) { |
|
98 | 98 | return $container['view']->render($response->withStatus(404), '404'); |
99 | 99 | }; |
100 | 100 | }; |
@@ -104,23 +104,23 @@ discard block |
||
104 | 104 | $translator = new \Core\Translator\Translator($container); |
105 | 105 | $translator->init(); |
106 | 106 | |
107 | -$container['translator'] = function () use ($translator) { |
|
107 | +$container['translator'] = function() use ($translator) { |
|
108 | 108 | return $translator; |
109 | 109 | }; |
110 | 110 | |
111 | 111 | |
112 | 112 | // Register provider |
113 | -$container['flash'] = function () { |
|
113 | +$container['flash'] = function() { |
|
114 | 114 | return new \Slim\Flash\Messages(); |
115 | 115 | }; |
116 | 116 | |
117 | 117 | |
118 | 118 | // |
119 | -$container['session'] = function ($container) { |
|
119 | +$container['session'] = function($container) { |
|
120 | 120 | $setting_session_driver = $container['settings']['session']['driver'] ?? 'session'; |
121 | 121 | |
122 | 122 | $sessionOBJ = new \Core\Services\Session(); |
123 | - $session = $sessionOBJ->init($setting_session_driver) ; |
|
123 | + $session = $sessionOBJ->init($setting_session_driver); |
|
124 | 124 | return $session; |
125 | 125 | }; |
126 | 126 | |
@@ -131,17 +131,17 @@ discard block |
||
131 | 131 | |
132 | 132 | |
133 | 133 | // Register Blade View helper |
134 | -$container['view'] = function ($container) { |
|
134 | +$container['view'] = function($container) { |
|
135 | 135 | $messages = $container->flash->getMessages(); |
136 | 136 | |
137 | - if(!is_dir('../app/View/cache')){ |
|
137 | + if (!is_dir('../app/View/cache')) { |
|
138 | 138 | @mkdir('../app/View/cache'); |
139 | 139 | } |
140 | 140 | |
141 | 141 | |
142 | 142 | $viewSettings = $container['settings']['view']; |
143 | 143 | return new \Slim\Views\Blade( |
144 | - [$viewSettings['blade_template_path'].$viewSettings['template']], |
|
144 | + [$viewSettings['blade_template_path'] . $viewSettings['template']], |
|
145 | 145 | $viewSettings['blade_cache_path'], |
146 | 146 | null, |
147 | 147 | [ |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | }; |
154 | 154 | |
155 | 155 | // Register Blade View helper |
156 | -$container['json'] = function ($container) { |
|
156 | +$container['json'] = function($container) { |
|
157 | 157 | return new \Core\Handlers\JsonHandler(); |
158 | 158 | }; |
159 | 159 | |
160 | -$app->getContainer()['view']->getRenderer()->getCompiler()->directive('helloWorld', function(){ |
|
160 | +$app->getContainer()['view']->getRenderer()->getCompiler()->directive('helloWorld', function() { |
|
161 | 161 | |
162 | 162 | return "<?php echo 'Hello Directive'; ?>"; |
163 | 163 | }); |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | |
173 | 173 | |
174 | 174 | /*Dynamic containers in services*/ |
175 | -$dir = scandir(__APP_ROOT__.'/core/Services/'); |
|
175 | +$dir = scandir(__APP_ROOT__ . '/core/Services/'); |
|
176 | 176 | $ex_folders = array('..', '.'); |
177 | -$filesInServices = array_diff($dir,$ex_folders); |
|
177 | +$filesInServices = array_diff($dir, $ex_folders); |
|
178 | 178 | |
179 | -foreach($filesInServices as $service){ |
|
180 | - $content = preg_replace('/.php/','',$service); |
|
181 | - $container[$content] = function () use ($content){ |
|
182 | - $class = '\\Core\\Services\\'.$content ; |
|
179 | +foreach ($filesInServices as $service) { |
|
180 | + $content = preg_replace('/.php/', '', $service); |
|
181 | + $container[$content] = function() use ($content){ |
|
182 | + $class = '\\Core\\Services\\' . $content; |
|
183 | 183 | return new $class(); |
184 | 184 | }; |
185 | 185 | } |
@@ -1,25 +1,25 @@ discard block |
||
1 | 1 | <?php |
2 | -define('__APP_ROOT__',__DIR__ . '/../') ; |
|
2 | +define('__APP_ROOT__', __DIR__ . '/../'); |
|
3 | 3 | $APPROOT = __APP_ROOT__; |
4 | -require __APP_ROOT__.'bootstrap/bootstrap.php'; |
|
5 | -require __APP_ROOT__.'vendor/autoload.php'; |
|
4 | +require __APP_ROOT__ . 'bootstrap/bootstrap.php'; |
|
5 | +require __APP_ROOT__ . 'vendor/autoload.php'; |
|
6 | 6 | |
7 | 7 | $env = new \Core\Helpers\Env(); |
8 | 8 | |
9 | 9 | defined('DS') || define('DS', DIRECTORY_SEPARATOR); |
10 | 10 | |
11 | 11 | /*Dynamic containers in services*/ |
12 | -$config_dir = scandir(__APP_ROOT__.'/config/'); |
|
12 | +$config_dir = scandir(__APP_ROOT__ . '/config/'); |
|
13 | 13 | $ex_config_folders = array('..', '.'); |
14 | -$filesInConfig = array_diff($config_dir,$ex_config_folders); |
|
14 | +$filesInConfig = array_diff($config_dir, $ex_config_folders); |
|
15 | 15 | if (!isset($configs)) { |
16 | 16 | $configs = array(); |
17 | 17 | } |
18 | -$i=0; |
|
19 | -foreach($filesInConfig as $config_file){ |
|
20 | - if($config_file === 'phpmig.php'){continue;} |
|
21 | - $file[$i] = include_once __APP_ROOT__.'config/'.$config_file; |
|
22 | - if(is_array($file[$i])){ |
|
18 | +$i = 0; |
|
19 | +foreach ($filesInConfig as $config_file) { |
|
20 | + if ($config_file === 'phpmig.php') {continue; } |
|
21 | + $file[$i] = include_once __APP_ROOT__ . 'config/' . $config_file; |
|
22 | + if (is_array($file[$i])) { |
|
23 | 23 | $configs = array_merge($configs, $file[$i]); |
24 | 24 | $i++; |
25 | 25 | } |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | } |
28 | 28 | |
29 | 29 | $config['settings'] = $configs; |
30 | -require __APP_ROOT__.'core/Functions/general_helpers.php'; |
|
30 | +require __APP_ROOT__ . 'core/Functions/general_helpers.php'; |
|
31 | 31 | |
32 | 32 | |
33 | 33 | $app = new \Core\App($config); |
34 | 34 | |
35 | -if($config['settings']['app']['debug'] && !$config['settings']['tracy']['active']){ |
|
35 | +if ($config['settings']['app']['debug'] && !$config['settings']['tracy']['active']) { |
|
36 | 36 | ini_set('display_errors', 1); |
37 | 37 | ini_set('display_startup_errors', 1); |
38 | 38 | error_reporting(E_ALL); |
@@ -41,18 +41,18 @@ discard block |
||
41 | 41 | |
42 | 42 | use SlimFacades\Facade; |
43 | 43 | // get container app |
44 | -require __APP_ROOT__.'bootstrap/dependencies.php'; |
|
44 | +require __APP_ROOT__ . 'bootstrap/dependencies.php'; |
|
45 | 45 | |
46 | -require __APP_ROOT__.'bootstrap/routes.php'; |
|
47 | -require __APP_ROOT__.'core/Functions/helpers.php'; |
|
46 | +require __APP_ROOT__ . 'bootstrap/routes.php'; |
|
47 | +require __APP_ROOT__ . 'core/Functions/helpers.php'; |
|
48 | 48 | |
49 | -if(php_sapi_name() != 'cli') { |
|
50 | - if($config['settings']['app']['debug'] && $config['settings']['tracy']['active']){ |
|
49 | +if (php_sapi_name() != 'cli') { |
|
50 | + if ($config['settings']['app']['debug'] && $config['settings']['tracy']['active']) { |
|
51 | 51 | Tracy\Debugger::enable(Tracy\Debugger::DEVELOPMENT, $config['settings']['tracy']['path']); |
52 | 52 | } |
53 | 53 | Facade::setFacadeApplication($app); |
54 | 54 | |
55 | - require __APP_ROOT__.'bootstrap/middlewares.php'; |
|
55 | + require __APP_ROOT__ . 'bootstrap/middlewares.php'; |
|
56 | 56 | |
57 | 57 | $app->run(); |
58 | 58 |