@@ -2,18 +2,18 @@ |
||
| 2 | 2 | use App\Controller\HomeController; |
| 3 | 3 | $route = new \Core\Route($app); |
| 4 | 4 | |
| 5 | -$files = getDirFiles(__APP_ROOT__.'app/Routes/'); |
|
| 5 | +$files = getDirFiles(__APP_ROOT__ . 'app/Routes/'); |
|
| 6 | 6 | /** Route Partial Loadup =================================================== */ |
| 7 | 7 | foreach ($files as $partial) { |
| 8 | - $file = __APP_ROOT__.'app/Routes/'.$partial; |
|
| 8 | + $file = __APP_ROOT__ . 'app/Routes/' . $partial; |
|
| 9 | 9 | |
| 10 | - if ( ! file_exists($file)) |
|
| 10 | + if (!file_exists($file)) |
|
| 11 | 11 | { |
| 12 | 12 | $msg = "Route partial [{$partial}] not found."; |
| 13 | 13 | } |
| 14 | 14 | include $file; |
| 15 | 15 | } |
| 16 | -$route->get('/', HomeController::class.':index')->setName('home'); |
|
| 16 | +$route->get('/', HomeController::class . ':index')->setName('home'); |
|
| 17 | 17 | |
| 18 | 18 | $route->resource('/user/auth', '\App\Controller\User\AuthController', $args = []); |
| 19 | 19 | |
@@ -1,26 +1,26 @@ |
||
| 1 | 1 | <?php |
| 2 | -define('__APP_ROOT__',__DIR__ . '/../') ; |
|
| 2 | +define('__APP_ROOT__', __DIR__ . '/../'); |
|
| 3 | 3 | |
| 4 | -require __APP_ROOT__.'bootstrap/bootstrap.php'; |
|
| 5 | -require __APP_ROOT__.'core/Functions/helpers.php'; |
|
| 6 | -require __APP_ROOT__.'vendor/autoload.php'; |
|
| 7 | -require __APP_ROOT__.'config/settings.php'; |
|
| 4 | +require __APP_ROOT__ . 'bootstrap/bootstrap.php'; |
|
| 5 | +require __APP_ROOT__ . 'core/Functions/helpers.php'; |
|
| 6 | +require __APP_ROOT__ . 'vendor/autoload.php'; |
|
| 7 | +require __APP_ROOT__ . 'config/settings.php'; |
|
| 8 | 8 | $app = new \Core\App($config); |
| 9 | 9 | |
| 10 | 10 | use SlimFacades\Facade; |
| 11 | 11 | // get container app |
| 12 | -require __APP_ROOT__.'bootstrap/dependencies.php'; |
|
| 13 | -require __APP_ROOT__.'bootstrap/routes.php'; |
|
| 12 | +require __APP_ROOT__ . 'bootstrap/dependencies.php'; |
|
| 13 | +require __APP_ROOT__ . 'bootstrap/routes.php'; |
|
| 14 | 14 | |
| 15 | -if(php_sapi_name() != 'cli') { |
|
| 15 | +if (php_sapi_name() != 'cli') { |
|
| 16 | 16 | $settings['tracy']['path'] = ''; |
| 17 | - if($app->getContainer() instanceof Psr\Container\ContainerInterface){ |
|
| 17 | + if ($app->getContainer() instanceof Psr\Container\ContainerInterface) { |
|
| 18 | 18 | $settings = $app->getContainer()->settings; |
| 19 | 19 | Tracy\Debugger::enable(Tracy\Debugger::DEVELOPMENT, $settings['tracy']['path']); |
| 20 | 20 | Facade::setFacadeApplication($app); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - require __APP_ROOT__.'bootstrap/middlewares.php'; |
|
| 23 | + require __APP_ROOT__ . 'bootstrap/middlewares.php'; |
|
| 24 | 24 | |
| 25 | 25 | $app->run(); |
| 26 | 26 | |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | /* database connection */ |
| 7 | 7 | |
| 8 | 8 | |
| 9 | -$container['db'] = function ($container) { |
|
| 9 | +$container['db'] = function($container) { |
|
| 10 | 10 | $db = $container['settings']['db']; |
| 11 | 11 | $pdo = new PDO("mysql:host=" . $db['host'] . ";dbname=" . $db['database'], |
| 12 | 12 | $db['username'], $db['password']); |
@@ -18,19 +18,19 @@ discard block |
||
| 18 | 18 | // |
| 19 | 19 | |
| 20 | 20 | |
| 21 | -$container['generalErrorHandler'] = function ($container) { |
|
| 21 | +$container['generalErrorHandler'] = function($container) { |
|
| 22 | 22 | return new \Core\Handlers\GeneralErrorHandler($container); |
| 23 | 23 | }; |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | // Service factory for the ORM |
| 28 | -$container['validator'] = function () { |
|
| 28 | +$container['validator'] = function() { |
|
| 29 | 29 | return new App\Validation\Validator(); |
| 30 | 30 | }; |
| 31 | 31 | |
| 32 | 32 | |
| 33 | -$container['eloquent'] = function ($container) { |
|
| 33 | +$container['eloquent'] = function($container) { |
|
| 34 | 34 | $capsule = new \Illuminate\Database\Capsule\Manager; |
| 35 | 35 | $capsule->addConnection($container['settings']['db']); |
| 36 | 36 | $capsule->setAsGlobal(); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | // monolog |
| 51 | -$container['logger'] = function ($c) { |
|
| 51 | +$container['logger'] = function($c) { |
|
| 52 | 52 | $settings = $c->get('settings')['logger']; |
| 53 | 53 | $logger = new Monolog\Logger($settings['name']); |
| 54 | 54 | $logger->pushProcessor(new Monolog\Processor\UidProcessor()); |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | }; |
| 58 | 58 | |
| 59 | 59 | // Register Blade View helper |
| 60 | -$container['view'] = function ($container) { |
|
| 60 | +$container['view'] = function($container) { |
|
| 61 | 61 | |
| 62 | 62 | $messages = $container->flash->getMessages(); |
| 63 | 63 | |
| 64 | 64 | $viewSettings = $container['settings']['view']; |
| 65 | 65 | return new \Slim\Views\Blade( |
| 66 | - [$viewSettings['blade_template_path'].$viewSettings['template']], |
|
| 66 | + [$viewSettings['blade_template_path'] . $viewSettings['template']], |
|
| 67 | 67 | $viewSettings['blade_cache_path'], |
| 68 | 68 | null, |
| 69 | 69 | [ |
@@ -76,13 +76,13 @@ discard block |
||
| 76 | 76 | $translator = new \Core\Translator\Translator($container); |
| 77 | 77 | $translator->init(); |
| 78 | 78 | |
| 79 | -$container['translator'] = function () use ($translator) { |
|
| 79 | +$container['translator'] = function() use ($translator) { |
|
| 80 | 80 | return $translator; |
| 81 | 81 | }; |
| 82 | 82 | |
| 83 | 83 | |
| 84 | 84 | // Register provider |
| 85 | -$container['flash'] = function () { |
|
| 85 | +$container['flash'] = function() { |
|
| 86 | 86 | return new \Slim\Flash\Messages(); |
| 87 | 87 | }; |
| 88 | 88 | |
@@ -97,14 +97,14 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | |
| 99 | 99 | /*Dynamic containers in services*/ |
| 100 | -$dir = scandir(__APP_ROOT__.'/core/Services/'); |
|
| 100 | +$dir = scandir(__APP_ROOT__ . '/core/Services/'); |
|
| 101 | 101 | $ex_folders = array('..', '.'); |
| 102 | -$filesInServices = array_diff($dir,$ex_folders); |
|
| 102 | +$filesInServices = array_diff($dir, $ex_folders); |
|
| 103 | 103 | |
| 104 | -foreach($filesInServices as $service){ |
|
| 105 | - $content = preg_replace('/.php/','',$service); |
|
| 106 | - $container[$content] = function () use ($content){ |
|
| 107 | - $class = '\\Core\\Services\\'.$content ; |
|
| 104 | +foreach ($filesInServices as $service) { |
|
| 105 | + $content = preg_replace('/.php/', '', $service); |
|
| 106 | + $container[$content] = function() use ($content){ |
|
| 107 | + $class = '\\Core\\Services\\' . $content; |
|
| 108 | 108 | return new $class(); |
| 109 | 109 | }; |
| 110 | 110 | } |
@@ -11,11 +11,11 @@ |
||
| 11 | 11 | |
| 12 | 12 | class Env |
| 13 | 13 | { |
| 14 | - public function __invoke($filePath ,$key, $default = null) |
|
| 14 | + public function __invoke($filePath, $key, $default = null) |
|
| 15 | 15 | { |
| 16 | 16 | |
| 17 | 17 | if (file_exists($filePath . '/.env')) { |
| 18 | - $_dotenv = new Dotenv($filePath ); |
|
| 18 | + $_dotenv = new Dotenv($filePath); |
|
| 19 | 19 | $_dotenv->load(); |
| 20 | 20 | unset($_dotenv); |
| 21 | 21 | }else { |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | $_dotenv = new Dotenv($filePath ); |
| 19 | 19 | $_dotenv->load(); |
| 20 | 20 | unset($_dotenv); |
| 21 | - }else { |
|
| 21 | + } else { |
|
| 22 | 22 | return ''; |
| 23 | 23 | } |
| 24 | 24 | |
@@ -8,15 +8,15 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | namespace Core\Helpers; |
| 10 | 10 | |
| 11 | -class Hash{ |
|
| 11 | +class Hash { |
|
| 12 | 12 | /** |
| 13 | 13 | * Receives a string password and hashes it. |
| 14 | 14 | * |
| 15 | 15 | * @param string $password |
| 16 | 16 | * @return string $hash |
| 17 | 17 | */ |
| 18 | - public static function hash($password){ |
|
| 19 | - return (string)password_hash($password, PASSWORD_DEFAULT); |
|
| 18 | + public static function hash($password) { |
|
| 19 | + return (string) password_hash($password, PASSWORD_DEFAULT); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | * @param string $hash |
| 27 | 27 | * @return boolean If the hash was generated from the password |
| 28 | 28 | */ |
| 29 | - public static function checkHash($string, $hash){ |
|
| 30 | - if( password_verify( $string, $hash ) ){ |
|
| 29 | + public static function checkHash($string, $hash) { |
|
| 30 | + if (password_verify($string, $hash)) { |
|
| 31 | 31 | return true; |
| 32 | 32 | } |
| 33 | 33 | return false; |