@@ -5,13 +5,13 @@ |
||
5 | 5 | |
6 | 6 | session_start(); |
7 | 7 | |
8 | -require __DIR__.'/../vendor/autoload.php'; |
|
8 | +require __DIR__ . '/../vendor/autoload.php'; |
|
9 | 9 | |
10 | 10 | if (!isset($_SERVER['APP_ENV'])) { |
11 | 11 | if (!class_exists(Dotenv::class)) { |
12 | 12 | throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.'); |
13 | 13 | } |
14 | - (new Dotenv())->load(__DIR__.'/../.env'); |
|
14 | + (new Dotenv())->load(__DIR__ . '/../.env'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | $app = new Application($_SERVER['APP_ENV'] ?? 'dev'); |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | return [ |
4 | 4 | |
5 | - 'sentinel' => require $app->getConfigurationDir().'/sentinel.php', |
|
5 | + 'sentinel' => require $app->getConfigurationDir() . '/sentinel.php', |
|
6 | 6 | |
7 | 7 | 'eloquent' => [ |
8 | 8 | 'driver' => $_SERVER['APP_DATABASE_DRIVER'], |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | |
18 | 18 | 'twig' => [ |
19 | 19 | 'path' => [ |
20 | - $app->getRootDir().'/templates' |
|
20 | + $app->getRootDir() . '/templates' |
|
21 | 21 | ], |
22 | 22 | 'options' => [ |
23 | - 'cache' => $app->getCacheDir().'/twig', |
|
23 | + 'cache' => $app->getCacheDir() . '/twig', |
|
24 | 24 | ] |
25 | 25 | ], |
26 | 26 | |
27 | 27 | 'monolog' => [ |
28 | 28 | 'name' => 'app', |
29 | - 'path' => $app->getLogDir().'/'.$app->getEnvironment().'.log', |
|
29 | + 'path' => $app->getLogDir() . '/' . $app->getEnvironment() . '.log', |
|
30 | 30 | 'level' => Monolog\Logger::ERROR |
31 | 31 | ] |
32 | 32 |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * |
16 | 16 | * https://www.slimframework.com/docs/objects/router.html#route-strategies |
17 | 17 | */ |
18 | -$container['foundHandler'] = function ($container) { |
|
18 | +$container['foundHandler'] = function($container) { |
|
19 | 19 | /** @var Request $request */ |
20 | 20 | $request = $container['request']; |
21 | 21 | $container['monolog']->info(sprintf('Matched route "%s /%s"', $request->getMethod(), ltrim($request->getUri()->getPath(), '/'))); |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | return new RequestResponseArgs(); |
24 | 24 | }; |
25 | 25 | |
26 | -$container['csrfFailureHandler'] = function ($container) { |
|
27 | - return function (Request $request, Response $response) use ($container) { |
|
26 | +$container['csrfFailureHandler'] = function($container) { |
|
27 | + return function(Request $request, Response $response) use ($container) { |
|
28 | 28 | $container['monolog']->error(sprintf('Failed CSRF check on "%s /%s"', $request->getMethod(), ltrim($request->getUri()->getPath(), '/'))); |
29 | 29 | |
30 | 30 | $container['flash']->addMessage('error', 'Failed CSRF check'); |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | }; |
38 | 38 | }; |
39 | 39 | |
40 | -$container['notFoundHandler'] = function ($container) { |
|
41 | - return function (Request $request, Response $response) use ($container) { |
|
40 | +$container['notFoundHandler'] = function($container) { |
|
41 | + return function(Request $request, Response $response) use ($container) { |
|
42 | 42 | $container['monolog']->error(sprintf('No route found for "%s /%s"', $request->getMethod(), ltrim($request->getUri()->getPath(), '/'))); |
43 | 43 | |
44 | 44 | if ('prod' === $this->getEnvironment()) { |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | }; |
50 | 50 | }; |
51 | 51 | |
52 | -$container['notAllowedHandler'] = function ($container) { |
|
53 | - return function (Request $request, Response $response, array $methods) use ($container) { |
|
52 | +$container['notAllowedHandler'] = function($container) { |
|
53 | + return function(Request $request, Response $response, array $methods) use ($container) { |
|
54 | 54 | $container['monolog']->error(sprintf( |
55 | 55 | 'No route found for "%s /%s": Method not allowed (Allow: %s)', |
56 | 56 | $request->getMethod(), |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | }; |
67 | 67 | }; |
68 | 68 | |
69 | -$container['accessDeniedHandler'] = function ($container) { |
|
70 | - return function (Request $request, Response $response, AccessDeniedException $exception) use ($container) { |
|
69 | +$container['accessDeniedHandler'] = function($container) { |
|
70 | + return function(Request $request, Response $response, AccessDeniedException $exception) use ($container) { |
|
71 | 71 | $container['monolog']->debug('Access denied, the user does not have access to this section', [ |
72 | 72 | 'exception' => $exception |
73 | 73 | ]); |
@@ -76,13 +76,13 @@ discard block |
||
76 | 76 | }; |
77 | 77 | }; |
78 | 78 | |
79 | -$container['errorHandler'] = function ($container) { |
|
80 | - return function (Request $request, Response $response, Exception $exception) use ($container) { |
|
79 | +$container['errorHandler'] = function($container) { |
|
80 | + return function(Request $request, Response $response, Exception $exception) use ($container) { |
|
81 | 81 | if ($exception instanceof AccessDeniedException) { |
82 | 82 | return $container['accessDeniedHandler']($request, $response, $exception); |
83 | 83 | } |
84 | 84 | |
85 | - $container['monolog']->error('Uncaught PHP Exception '.get_class($exception), [ |
|
85 | + $container['monolog']->error('Uncaught PHP Exception ' . get_class($exception), [ |
|
86 | 86 | 'exception' => $exception |
87 | 87 | ]); |
88 | 88 | |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | }; |
95 | 95 | }; |
96 | 96 | |
97 | -$container['phpErrorHandler'] = function ($container) { |
|
98 | - return function (Request $request, Response $response, Throwable $error) use ($container) { |
|
99 | - $container['monolog']->critical('Uncaught PHP Exception '.get_class($error), [ |
|
97 | +$container['phpErrorHandler'] = function($container) { |
|
98 | + return function(Request $request, Response $response, Throwable $error) use ($container) { |
|
99 | + $container['monolog']->critical('Uncaught PHP Exception ' . get_class($error), [ |
|
100 | 100 | 'exception' => $error |
101 | 101 | ]); |
102 | 102 |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$config = require $app->getConfigurationDir().'/services.php'; |
|
3 | +$config = require $app->getConfigurationDir() . '/services.php'; |
|
4 | 4 | |
5 | 5 | $config['twig']['options']['debug'] = true; |
6 | 6 | $config['twig']['options']['auto_reload'] = true; |
@@ -5,9 +5,9 @@ discard block |
||
5 | 5 | use Illuminate\Database\Capsule\Manager; |
6 | 6 | use Illuminate\Database\Schema\Blueprint; |
7 | 7 | |
8 | -$sentinel = (new Sentinel(new SentinelBootstrapper(__DIR__.'/../sentinel.php')))->getSentinel(); |
|
8 | +$sentinel = (new Sentinel(new SentinelBootstrapper(__DIR__ . '/../sentinel.php')))->getSentinel(); |
|
9 | 9 | |
10 | -Manager::schema()->create('user', function (Blueprint $table) { |
|
10 | +Manager::schema()->create('user', function(Blueprint $table) { |
|
11 | 11 | $table->increments('id'); |
12 | 12 | $table->string('username')->unique(); |
13 | 13 | $table->string('email')->unique(); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $table->timestamps(); |
20 | 20 | }); |
21 | 21 | |
22 | -Manager::schema()->create('activations', function (Blueprint $table) { |
|
22 | +Manager::schema()->create('activations', function(Blueprint $table) { |
|
23 | 23 | $table->increments('id'); |
24 | 24 | $table->unsignedInteger('user_id'); |
25 | 25 | $table->string('code'); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $table->foreign('user_id')->references('id')->on('user'); |
30 | 30 | }); |
31 | 31 | |
32 | -Manager::schema()->create('persistences', function (Blueprint $table) { |
|
32 | +Manager::schema()->create('persistences', function(Blueprint $table) { |
|
33 | 33 | $table->increments('id'); |
34 | 34 | $table->unsignedInteger('user_id'); |
35 | 35 | $table->string('code')->unique(); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $table->foreign('user_id')->references('id')->on('user'); |
38 | 38 | }); |
39 | 39 | |
40 | -Manager::schema()->create('reminders', function (Blueprint $table) { |
|
40 | +Manager::schema()->create('reminders', function(Blueprint $table) { |
|
41 | 41 | $table->increments('id'); |
42 | 42 | $table->unsignedInteger('user_id'); |
43 | 43 | $table->string('code'); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $table->foreign('user_id')->references('id')->on('user'); |
48 | 48 | }); |
49 | 49 | |
50 | -Manager::schema()->create('roles', function (Blueprint $table) { |
|
50 | +Manager::schema()->create('roles', function(Blueprint $table) { |
|
51 | 51 | $table->increments('id'); |
52 | 52 | $table->string('slug')->unique(); |
53 | 53 | $table->string('name'); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $table->timestamps(); |
56 | 56 | }); |
57 | 57 | |
58 | -Manager::schema()->create('role_users', function (Blueprint $table) { |
|
58 | +Manager::schema()->create('role_users', function(Blueprint $table) { |
|
59 | 59 | $table->unsignedInteger('user_id'); |
60 | 60 | $table->unsignedInteger('role_id'); |
61 | 61 | $table->timestamps(); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $table->foreign('role_id')->references('id')->on('roles'); |
65 | 65 | }); |
66 | 66 | |
67 | -Manager::schema()->create('throttle', function (Blueprint $table) { |
|
67 | +Manager::schema()->create('throttle', function(Blueprint $table) { |
|
68 | 68 | $table->increments('id'); |
69 | 69 | $table->integer('user_id')->unsigned()->nullable(); |
70 | 70 | $table->string('type'); |
@@ -3,8 +3,8 @@ |
||
3 | 3 | Illuminate\Database\Capsule\Manager::schema()->defaultStringLength(191); |
4 | 4 | |
5 | 5 | // Drop all tables |
6 | -require __DIR__.'/drop.php'; |
|
6 | +require __DIR__ . '/drop.php'; |
|
7 | 7 | |
8 | 8 | // Create tables |
9 | -require __DIR__.'/auth.php'; |
|
10 | -require __DIR__.'/app.php'; |
|
9 | +require __DIR__ . '/auth.php'; |
|
10 | +require __DIR__ . '/app.php'; |
@@ -21,16 +21,16 @@ discard block |
||
21 | 21 | $capsule->setAsGlobal(); |
22 | 22 | $capsule->bootEloquent(); |
23 | 23 | |
24 | -$container['auth'] = function ($container) { |
|
24 | +$container['auth'] = function($container) { |
|
25 | 25 | $sentinel = new Sentinel(new SentinelBootstrapper($container['settings']['sentinel'])); |
26 | 26 | return $sentinel->getSentinel(); |
27 | 27 | }; |
28 | 28 | |
29 | -$container['flash'] = function () { |
|
29 | +$container['flash'] = function() { |
|
30 | 30 | return new Messages(); |
31 | 31 | }; |
32 | 32 | |
33 | -$container['csrf'] = function ($container) { |
|
33 | +$container['csrf'] = function($container) { |
|
34 | 34 | $guard = new Guard(); |
35 | 35 | $guard->setFailureCallable($container['csrfFailureHandler']); |
36 | 36 | |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | }; |
39 | 39 | |
40 | 40 | // https://github.com/awurth/SlimValidation |
41 | -$container['validator'] = function () { |
|
41 | +$container['validator'] = function() { |
|
42 | 42 | return new Validator(); |
43 | 43 | }; |
44 | 44 | |
45 | -$container['twig'] = function ($container) { |
|
45 | +$container['twig'] = function($container) { |
|
46 | 46 | $config = $container['settings']['twig']; |
47 | 47 | |
48 | 48 | $twig = new Twig($config['path'], $config['options']); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | return $twig; |
60 | 60 | }; |
61 | 61 | |
62 | -$container['monolog'] = function ($container) { |
|
62 | +$container['monolog'] = function($container) { |
|
63 | 63 | $config = $container['settings']['monolog']; |
64 | 64 | |
65 | 65 | $logger = new Logger($config['name']); |
@@ -56,7 +56,7 @@ |
||
56 | 56 | if (!class_exists(Dotenv::class)) { |
57 | 57 | throw new \RuntimeException('APP_TEST_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.'); |
58 | 58 | } |
59 | - (new Dotenv())->load(__DIR__.'/../.env'); |
|
59 | + (new Dotenv())->load(__DIR__ . '/../.env'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $app = new Application($_SERVER['APP_TEST_ENV'] ?? 'test'); |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | |
38 | 38 | public function getCacheDir() |
39 | 39 | { |
40 | - return $this->getRootDir().'/var/cache/'.$this->environment; |
|
40 | + return $this->getRootDir() . '/var/cache/' . $this->environment; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | public function getConfigurationDir() |
44 | 44 | { |
45 | - return $this->getRootDir().'/config'; |
|
45 | + return $this->getRootDir() . '/config'; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | public function getEnvironment() |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | public function getLogDir() |
54 | 54 | { |
55 | - return $this->getRootDir().'/var/log'; |
|
55 | + return $this->getRootDir() . '/var/log'; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | public function getRootDir() |
@@ -67,20 +67,20 @@ discard block |
||
67 | 67 | protected function configureContainer() |
68 | 68 | { |
69 | 69 | $container = $this->getContainer(); |
70 | - require $this->getConfigurationDir().'/container.php'; |
|
70 | + require $this->getConfigurationDir() . '/container.php'; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | protected function loadConfiguration() |
74 | 74 | { |
75 | 75 | $app = $this; |
76 | 76 | $configuration = [ |
77 | - 'settings' => require $this->getConfigurationDir().'/slim.php' |
|
77 | + 'settings' => require $this->getConfigurationDir() . '/slim.php' |
|
78 | 78 | ]; |
79 | 79 | |
80 | - if (file_exists($this->getConfigurationDir().'/services.'.$this->getEnvironment().'.php')) { |
|
81 | - $configuration['settings'] += require $this->getConfigurationDir().'/services.'.$this->getEnvironment().'.php'; |
|
80 | + if (file_exists($this->getConfigurationDir() . '/services.' . $this->getEnvironment() . '.php')) { |
|
81 | + $configuration['settings'] += require $this->getConfigurationDir() . '/services.' . $this->getEnvironment() . '.php'; |
|
82 | 82 | } else { |
83 | - $configuration['settings'] += require $this->getConfigurationDir().'/services.php'; |
|
83 | + $configuration['settings'] += require $this->getConfigurationDir() . '/services.php'; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $configuration; |
@@ -90,23 +90,23 @@ discard block |
||
90 | 90 | { |
91 | 91 | $app = $this; |
92 | 92 | $container = $this->getContainer(); |
93 | - require $this->getConfigurationDir().'/middleware.php'; |
|
93 | + require $this->getConfigurationDir() . '/middleware.php'; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | protected function loadRoutes() |
97 | 97 | { |
98 | 98 | $app = $this; |
99 | 99 | $container = $this->getContainer(); |
100 | - require $this->getConfigurationDir().'/routes.php'; |
|
100 | + require $this->getConfigurationDir() . '/routes.php'; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | protected function registerControllers() |
104 | 104 | { |
105 | 105 | $container = $this->getContainer(); |
106 | - if (file_exists($this->getConfigurationDir().'/controllers.php')) { |
|
107 | - $controllers = require $this->getConfigurationDir().'/controllers.php'; |
|
106 | + if (file_exists($this->getConfigurationDir() . '/controllers.php')) { |
|
107 | + $controllers = require $this->getConfigurationDir() . '/controllers.php'; |
|
108 | 108 | foreach ($controllers as $key => $class) { |
109 | - $container[$key] = function ($container) use ($class) { |
|
109 | + $container[$key] = function($container) use ($class) { |
|
110 | 110 | return new $class($container); |
111 | 111 | }; |
112 | 112 | } |
@@ -116,6 +116,6 @@ discard block |
||
116 | 116 | protected function registerHandlers() |
117 | 117 | { |
118 | 118 | $container = $this->getContainer(); |
119 | - require $this->getConfigurationDir().'/handlers.php'; |
|
119 | + require $this->getConfigurationDir() . '/handlers.php'; |
|
120 | 120 | } |
121 | 121 | } |