@@ -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,8 +57,8 @@ discard block |
||
| 57 | 57 | }; |
| 58 | 58 | |
| 59 | 59 | // not found handler |
| 60 | -$container['notFoundHandler'] = function ($container) { |
|
| 61 | - return function (\Slim\Http\Request $request, \Slim\Http\Response $response) use ($container) { |
|
| 60 | +$container['notFoundHandler'] = function($container) { |
|
| 61 | + return function(\Slim\Http\Request $request, \Slim\Http\Response $response) use ($container) { |
|
| 62 | 62 | return $container['view']->render($response->withStatus(404), '404'); |
| 63 | 63 | }; |
| 64 | 64 | }; |
@@ -68,13 +68,13 @@ discard block |
||
| 68 | 68 | $translator = new \Core\Translator\Translator($container); |
| 69 | 69 | $translator->init(); |
| 70 | 70 | |
| 71 | -$container['translator'] = function () use ($translator) { |
|
| 71 | +$container['translator'] = function() use ($translator) { |
|
| 72 | 72 | return $translator; |
| 73 | 73 | }; |
| 74 | 74 | |
| 75 | 75 | |
| 76 | 76 | // Register provider |
| 77 | -$container['flash'] = function () { |
|
| 77 | +$container['flash'] = function() { |
|
| 78 | 78 | return new \Slim\Flash\Messages(); |
| 79 | 79 | }; |
| 80 | 80 | |
@@ -82,14 +82,14 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | |
| 84 | 84 | // Register Blade View helper |
| 85 | -$container['view'] = function ($container) { |
|
| 85 | +$container['view'] = function($container) { |
|
| 86 | 86 | |
| 87 | 87 | $messages = $container->flash->getMessages(); |
| 88 | 88 | |
| 89 | 89 | $viewSettings = $container['settings']['view']; |
| 90 | 90 | |
| 91 | 91 | return new \Slim\Views\Blade( |
| 92 | - [$viewSettings['blade_template_path'].$viewSettings['template']], |
|
| 92 | + [$viewSettings['blade_template_path'] . $viewSettings['template']], |
|
| 93 | 93 | $viewSettings['blade_cache_path'], |
| 94 | 94 | null, |
| 95 | 95 | [ |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | ] |
| 100 | 100 | ); |
| 101 | 101 | }; |
| 102 | -$app->getContainer()['view']->getRenderer()->getCompiler()->directive('helloWorld', function(){ |
|
| 102 | +$app->getContainer()['view']->getRenderer()->getCompiler()->directive('helloWorld', function() { |
|
| 103 | 103 | |
| 104 | 104 | return "<?php echo 'Hello Directive'; ?>"; |
| 105 | 105 | }); |
@@ -112,14 +112,14 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | |
| 114 | 114 | /*Dynamic containers in services*/ |
| 115 | -$dir = scandir(__APP_ROOT__.'/core/Services/'); |
|
| 115 | +$dir = scandir(__APP_ROOT__ . '/core/Services/'); |
|
| 116 | 116 | $ex_folders = array('..', '.'); |
| 117 | -$filesInServices = array_diff($dir,$ex_folders); |
|
| 117 | +$filesInServices = array_diff($dir, $ex_folders); |
|
| 118 | 118 | |
| 119 | -foreach($filesInServices as $service){ |
|
| 120 | - $content = preg_replace('/.php/','',$service); |
|
| 121 | - $container[$content] = function () use ($content){ |
|
| 122 | - $class = '\\Core\\Services\\'.$content ; |
|
| 119 | +foreach ($filesInServices as $service) { |
|
| 120 | + $content = preg_replace('/.php/', '', $service); |
|
| 121 | + $container[$content] = function() use ($content){ |
|
| 122 | + $class = '\\Core\\Services\\' . $content; |
|
| 123 | 123 | return new $class(); |
| 124 | 124 | }; |
| 125 | 125 | } |
@@ -5,5 +5,5 @@ |
||
| 5 | 5 | $dir = scandir($path); |
| 6 | 6 | $ex_folders = array('..', '.'); |
| 7 | 7 | |
| 8 | - return array_diff($dir,$ex_folders); |
|
| 8 | + return array_diff($dir, $ex_folders); |
|
| 9 | 9 | } |
@@ -19,9 +19,9 @@ discard block |
||
| 19 | 19 | { |
| 20 | 20 | $this->container = $container; |
| 21 | 21 | } |
| 22 | - public function get( $name, $params = array() ) |
|
| 22 | + public function get($name, $params = array()) |
|
| 23 | 23 | { |
| 24 | - $route = $this->container->get('router')->pathFor($name,$params); |
|
| 24 | + $route = $this->container->get('router')->pathFor($name, $params); |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | return $route; |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | $protocol = $request->getUri()->getScheme(); |
| 48 | 48 | $baseHost = $request->getUri()->getHost(); |
| 49 | 49 | $path = $request->getUri()->getPath(); |
| 50 | - $pathArr = explode('/',$path); |
|
| 51 | - unset($pathArr[count($pathArr)-1]); |
|
| 52 | - $path = implode('/',$pathArr); |
|
| 50 | + $pathArr = explode('/', $path); |
|
| 51 | + unset($pathArr[count($pathArr) - 1]); |
|
| 52 | + $path = implode('/', $pathArr); |
|
| 53 | 53 | $port = $request->getUri()->getPort() ? ':' . $request->getUri()->getPort() : ''; |
| 54 | 54 | $baseUrl = $protocol . '://' . $baseHost . $port . $path; |
| 55 | 55 | return $baseUrl; |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | 'displayErrorDetails' => true, |
| 13 | 13 | 'addContentLengthHeader' => false, |
| 14 | 14 | 'determineRouteBeforeAppMiddleware' => true, |
| 15 | - 'debug'=>true , |
|
| 15 | + 'debug'=>true, |
|
| 16 | 16 | 'translation' => [ |
| 17 | 17 | 'default_lang' => 'en', |
| 18 | 18 | 'translations_path' => $APPROOT . 'translations/', |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | 'path' => __DIR__ . '/../storage/logs/app.log', |
| 27 | 27 | ], |
| 28 | 28 | 'db' => [ |
| 29 | - 'driver' => $env($APPROOT,'DB_DRIVER', 'mysql'), |
|
| 30 | - 'host' => $env($APPROOT,'DB_HOST', 'localhost'), |
|
| 31 | - 'database' => $env($APPROOT,'DB_NAME', 'cafesaba'), |
|
| 32 | - 'username' => $env($APPROOT,'DB_USERNAME', 'root'), |
|
| 33 | - 'password' => $env($APPROOT,'DB_PASS', 'root'), |
|
| 34 | - 'charset' => $env($APPROOT,'DB_CHARSET', 'utf8'), |
|
| 35 | - 'collation' => $env($APPROOT,'DB_COLLATION', 'utf8_unicode_ci'), |
|
| 36 | - 'prefix' => $env($APPROOT,'DB_PREFIX', ''), |
|
| 37 | - 'port' => $env($APPROOT,'DB_PORT', 3306), |
|
| 29 | + 'driver' => $env($APPROOT, 'DB_DRIVER', 'mysql'), |
|
| 30 | + 'host' => $env($APPROOT, 'DB_HOST', 'localhost'), |
|
| 31 | + 'database' => $env($APPROOT, 'DB_NAME', 'cafesaba'), |
|
| 32 | + 'username' => $env($APPROOT, 'DB_USERNAME', 'root'), |
|
| 33 | + 'password' => $env($APPROOT, 'DB_PASS', 'root'), |
|
| 34 | + 'charset' => $env($APPROOT, 'DB_CHARSET', 'utf8'), |
|
| 35 | + 'collation' => $env($APPROOT, 'DB_COLLATION', 'utf8_unicode_ci'), |
|
| 36 | + 'prefix' => $env($APPROOT, 'DB_PREFIX', ''), |
|
| 37 | + 'port' => $env($APPROOT, 'DB_PORT', 3306), |
|
| 38 | 38 | ], |
| 39 | 39 | 'view' => [ |
| 40 | 40 | 'path' => '../app/View', |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | 'showSlimEnvironmentPanel' => 1, |
| 55 | 55 | 'showSlimRequestPanel' => 1, |
| 56 | 56 | 'showSlimResponsePanel' => 1, |
| 57 | - 'showSlimContainer' =>1 , |
|
| 57 | + 'showSlimContainer' =>1, |
|
| 58 | 58 | 'showEloquentORMPanel' => 1, |
| 59 | - 'showIdiormPanel' => 0,// > 0 mean you enable logging |
|
| 59 | + 'showIdiormPanel' => 0, // > 0 mean you enable logging |
|
| 60 | 60 | // but show or not panel you decide in browser in panel selector |
| 61 | - 'showDoctrinePanel' => 'em',// here also enable logging and you must enter your Doctrine container name |
|
| 61 | + 'showDoctrinePanel' => 'em', // here also enable logging and you must enter your Doctrine container name |
|
| 62 | 62 | // and also as above show or not panel you decide in browser in panel selector |
| 63 | 63 | 'showProfilerPanel' => 1, |
| 64 | 64 | 'showVendorVersionsPanel' => 1, |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -if($config['settings']['debug'] && $config['settings']['tracy']['active']) { |
|
| 2 | +if ($config['settings']['debug'] && $config['settings']['tracy']['active']) { |
|
| 3 | 3 | $app->add(new RunTracy\Middlewares\TracyMiddleware($app)); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -1,15 +1,15 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -define('__APP_ROOT__',__DIR__ . '/../') ; |
|
| 3 | -require __APP_ROOT__.'bootstrap/bootstrap.php'; |
|
| 4 | -require __APP_ROOT__.'vendor/autoload.php'; |
|
| 5 | -require __APP_ROOT__.'config/settings.php'; |
|
| 2 | +define('__APP_ROOT__', __DIR__ . '/../'); |
|
| 3 | +require __APP_ROOT__ . 'bootstrap/bootstrap.php'; |
|
| 4 | +require __APP_ROOT__ . 'vendor/autoload.php'; |
|
| 5 | +require __APP_ROOT__ . 'config/settings.php'; |
|
| 6 | 6 | |
| 7 | -require __APP_ROOT__.'core/Functions/general_helpers.php'; |
|
| 7 | +require __APP_ROOT__ . 'core/Functions/general_helpers.php'; |
|
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | $app = new \Core\App($config); |
| 11 | 11 | |
| 12 | -if($config['settings']['debug'] && !$config['settings']['tracy']['active']){ |
|
| 12 | +if ($config['settings']['debug'] && !$config['settings']['tracy']['active']) { |
|
| 13 | 13 | ini_set('display_errors', 1); |
| 14 | 14 | ini_set('display_startup_errors', 1); |
| 15 | 15 | error_reporting(E_ALL); |
@@ -18,18 +18,18 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | use SlimFacades\Facade; |
| 20 | 20 | // get container app |
| 21 | -require __APP_ROOT__.'bootstrap/dependencies.php'; |
|
| 21 | +require __APP_ROOT__ . 'bootstrap/dependencies.php'; |
|
| 22 | 22 | |
| 23 | -require __APP_ROOT__.'bootstrap/routes.php'; |
|
| 24 | -require __APP_ROOT__.'core/Functions/helpers.php'; |
|
| 23 | +require __APP_ROOT__ . 'bootstrap/routes.php'; |
|
| 24 | +require __APP_ROOT__ . 'core/Functions/helpers.php'; |
|
| 25 | 25 | |
| 26 | -if(php_sapi_name() != 'cli') { |
|
| 27 | - if($config['settings']['debug'] && $config['settings']['tracy']['active']){ |
|
| 26 | +if (php_sapi_name() != 'cli') { |
|
| 27 | + if ($config['settings']['debug'] && $config['settings']['tracy']['active']) { |
|
| 28 | 28 | Tracy\Debugger::enable(Tracy\Debugger::DEVELOPMENT, $config['settings']['tracy']['path']); |
| 29 | 29 | } |
| 30 | 30 | Facade::setFacadeApplication($app); |
| 31 | 31 | |
| 32 | - require __APP_ROOT__.'bootstrap/middlewares.php'; |
|
| 32 | + require __APP_ROOT__ . 'bootstrap/middlewares.php'; |
|
| 33 | 33 | |
| 34 | 34 | $app->run(); |
| 35 | 35 | |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | /** |
| 16 | 16 | * @param Core\Services\AuthService\AuthService |
| 17 | 17 | * @return AuthService |
| 18 | - */ |
|
| 18 | + */ |
|
| 19 | 19 | protected static function getFacadeAccessor() |
| 20 | 20 | { |
| 21 | 21 | return 'AuthService'; |
@@ -2,22 +2,22 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | |
| 5 | -function route(string $name ,array $params = []) |
|
| 5 | +function route(string $name, array $params = []) |
|
| 6 | 6 | { |
| 7 | 7 | $url = new \Core\Helpers\Url($GLOBALS['container']); |
| 8 | - return $url->get($name , $params); |
|
| 8 | + return $url->get($name, $params); |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | -function url(string $name ,array $params = []) |
|
| 11 | +function url(string $name, array $params = []) |
|
| 12 | 12 | { |
| 13 | 13 | $url = new \Core\Helpers\Url($GLOBALS['container']); |
| 14 | - return $url->get($name , $params); |
|
| 14 | + return $url->get($name, $params); |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // translate |
| 18 | -function trans($key , $replace = []){ |
|
| 18 | +function trans($key, $replace = []) { |
|
| 19 | 19 | $container = $GLOBALS['container']; |
| 20 | - return $container->translator->trans($key,$replace); |
|
| 20 | + return $container->translator->trans($key, $replace); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | function public_path(string $uri = '') { |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | $url = new \Core\Helpers\Url($container); |
| 29 | 29 | |
| 30 | - $url_asset = $url->getBaseRoutePath($request) .'/'. $uri; |
|
| 30 | + $url_asset = $url->getBaseRoutePath($request) . '/' . $uri; |
|
| 31 | 31 | return $url_asset; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | function asset(string $uri = '') { |
| 35 | 35 | $url = public_path(); |
| 36 | - $url_asset = $url.'assets/'.$uri; |
|
| 36 | + $url_asset = $url . 'assets/' . $uri; |
|
| 37 | 37 | return $url_asset; |
| 38 | 38 | } |
| 39 | 39 | |