@@ -45,10 +45,31 @@ Create an entrypoint for console
4545It's a script similar to ` www/index.php ` , it just gets ` Symfony\Component\Console\Application ` from DI container and
4646runs it.
4747
48- Create a file called ` bin/console ` and make sure it is executable - ` touch bin/console && chmod +x bin/console ` . After
49- that just copy and paste one of following snippets into the file.
48+ Create a file called ` bin/console ` and make sure it is executable - ` touch bin/console && chmod +x bin/console ` .
49+ To commit executable permission to git, use ` git update-index --chmod=+x bin/console ` .
50+ After that copy and paste one of following snippets into the file.
5051
51- For Nette 3.0+ [ web-project] ( https://github.com/nette/web-project ) structure, it should look like this:
52+ <details open >
53+ <summary>For <a href="https://github.com/nette/web-project">nette/web-project</a> 3.3+ structure</summary>
54+
55+ ``` php
56+ #!/usr/bin/env php
57+ <?php declare(strict_types = 1);
58+
59+ use App\Bootstrap;
60+ use Symfony\Component\Console\Application;
61+
62+ require __DIR__ . '/../vendor/autoload.php';
63+
64+ $bootstrap = new Bootstrap();
65+ $container = $bootstrap->bootWebApplication();
66+ $application = $container->getByType(Application::class);
67+ exit($application->run());
68+ ```
69+ </details >
70+
71+ <details >
72+ <summary>Nette 3.0 - 3.2</summary>
5273
5374``` php
5475#!/usr/bin/env php
@@ -64,8 +85,10 @@ $container = $configurator->createContainer();
6485$application = $container->getByType(Application::class);
6586exit($application->run());
6687```
88+ </details >
6789
68- For structure of Nette <=2.4:
90+ <details >
91+ <summary>Nette <= 2.4</summary>
6992
7093``` php
7194#!/usr/bin/env php
@@ -78,6 +101,7 @@ $container = require __DIR__ . '/../app/bootstrap.php';
78101$application = $container->getByType(Application::class);
79102exit($application->run());
80103```
104+ </details >
81105
82106Now you should be able to run console via ` php bin/console ` . In most of the environments should also work ` bin/console ` .
83107
0 commit comments