These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | if (php_sapi_name() == 'cli-server') { |
||
3 | putenv('SECRET_KEY=test-key'); |
||
4 | } |
||
5 | |||
6 | if (getenv('APPLICATION_ENV') == 'develop') { |
||
7 | define('DEBUG_MODE', 1); |
||
8 | error_reporting(E_ALL); |
||
9 | } |
||
10 | |||
11 | // Super debug func |
||
12 | function prr($value) |
||
13 | { |
||
14 | if (defined('DEBUG_MODE') && DEBUG_MODE == 1) { |
||
15 | echo '<pre>'; |
||
16 | print_r($value); |
||
17 | echo '</pre>'; |
||
18 | }; |
||
19 | } |
||
20 | |||
21 | // Load all class |
||
22 | require __DIR__.'/../vendor/autoload.php'; |
||
23 | |||
24 | // Load application settings |
||
25 | $settings = require __DIR__.'/../app/settings.php'; |
||
26 | |||
27 | // Create container for application |
||
28 | $container = new \Slim\Container($settings); |
||
29 | |||
30 | // Register service providers & factories |
||
31 | $container->register(new \App\Providers\LogServiceProvider()); |
||
32 | $container->register(new \App\Providers\RendererServiceProvider()); |
||
33 | $container->register(new \App\Providers\AclServiceProvider()); |
||
34 | $container->register(new \App\Providers\DatabaseServiceProvider()); |
||
35 | $container->register(new \App\Providers\ValidationServiceProvider()); |
||
36 | $container->register(new \App\Providers\MailerServiceProvider()); |
||
37 | $container->register(new \App\Providers\ErrorHandlerServiceProvider()); |
||
38 | $container->register(new \App\Providers\EncoderServiceProvider()); |
||
39 | |||
40 | // Create new application |
||
41 | $app = new \Slim\App($container); |
||
42 | |||
43 | // Register middleware |
||
44 | $app->add(new \App\Middleware\Logger($app->getContainer()->get('logger'))); |
||
45 | $app->add(new \App\Middleware\CustomException($app->getContainer()->get('apiRenderer'))); |
||
46 | |||
47 | // Register routes |
||
48 | require __DIR__.'/../app/routes.php'; |
||
49 | |||
50 | // Run! |
||
51 | $app->run(); |
||
52 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.