Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

bootstrap.php returns DI container and index.php runs the application

  • Loading branch information...
commit a62ff788250ed00bc4f50417870b775ef0e35237 1 parent 6656c1c
@dg dg authored
Showing with 7 additions and 11 deletions.
  1. +1 −8 app/bootstrap.php
  2. +6 −3 www/index.php
9 app/bootstrap.php
@@ -1,14 +1,9 @@
- * My Application bootstrap file.
- */
// Load Nette Framework or autoloader generated by Composer
require __DIR__ . '/../libs/autoload.php';
-// Configure application
$configurator = new Nette\Config\Configurator;
// Enable Nette Debugger for error visualisation & logging
@@ -27,6 +22,4 @@
$configurator->addConfig(__DIR__ . '/config/config.local.neon');
$container = $configurator->createContainer();
-// Configure and run the application!
+return $container;
9 www/index.php
@@ -1,7 +1,10 @@
-// uncomment this line if you must temporarily take down your site for maintenance
+// Uncomment this line if you must temporarily take down your site for maintenance.
// require '.maintenance.php';
-// load bootstrap file
-require __DIR__ . '/../app/bootstrap.php';
+// Let bootstrap create Dependency Injection container.
+$container = require __DIR__ . '/../app/bootstrap.php';
+// Run application.

5 comments on commit a62ff78


Great to see this! I wanted to propose this change for some time but have never find a moment to write down my reasoning.


And what is your reason? ;)


Bootstrapping (preparing) the whole application but not executing it's default entry point. That's useful for

  • testing - load the app and test only part
  • phpsh - load the app and then play with CLI
  • CLI scripts, because I don't want to run presenters from cron

The approach is similar to Misko's main() method - which is index.php in our case


Thanks. I have the same reasons.


This is just great! :+1:

Please sign in to comment.
Something went wrong with that request. Please try again.