06.
Explore! Environments & Config Files
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
8 Comments
I think that it's more intuitive if the boot function was outside the handle function
<br />$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);<br />$kernel->boot();<br />$request = Request::createFromGlobals();<br />$response = $kernel->handle($request);<br />$response->send();<br />$kernel->terminate($request, $response);<br />So the handle request function only captures the request
Hey Helmi
I think it's fine the way it is because I don't think it should be the user responsibility to boot up the kernel, unless you have a valid use-case for it
Cheers!
Hello,
In the <b>routing loading paragraph </b>you said : <i>And the configureRoutes() method is pretty much the same: it automatically loads everything from the config/routes directory and then looks for an environment-specific subdirectory:</i>.
In symfony 4.3 this is the <i>configureRoutes</i> function, if you read it , I think they change the order of loading routing files, environment-specific subdirectory first, then it loads config/routes directory
`
protected function configureRoutes(RouteCollectionBuilder $routes): void
{
$confDir = $this->getProjectDir().'/config';
$routes->import($confDir.'/{routes}/'.$this->environment.'/**/'.self::CONFIG_EXTS, '/', 'glob'); $routes->import($confDir.'/{routes}/'.self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob');
}
`
Hey mehdi
Woh, nice catch! You made dug deep. I found the commit when Symfony changed that line: https://github.com/symfony/...
The reason is at the top of the page
Cheers!
November 2018 Update:
A) The .env.dist file no longer exists. Its contents should be moved to your .env file (see the next point).
Source: https://symfony.com/doc/cur...
Hey Mike P.!
You're totally right! And we've added some notes to the video about that to help make sure people are aware. Was there a spot in this video where we talked about .env.dist that you found confusing because we didn't make this Nov 2018 updates obvious? Let us know - we'll definitely add any other notes we need to help people.
Cheers!
For a personal application I'm coding up on Symfony 4, I added this application specific parameters under config/services.yml https://gist.github.com/elv...
Now my question is, how is the best way/practice for my code under /src (Controllers, Services, Helpers, etc) to get this parameters values?
Thanks,
Hey Elvism,
Well, there're a few possible ways but it depends. For example, if we're talking about controllers - you can extend Symfony base controller and then you'll have "$this->getParameter()" shortcut, or, if you have an access to the DI container - call it via "$this->container->getParameter()". Fo example, if you want to get a value of "app.pool_acct" parameters, get it with:
$this->getParameter('app.pool_acct').
If we're talking about services, you need to pass parameters explicitly on service definition of as an argument like:
App\Service\MyService:
arguments:
- '%app.pool_acct%'
Where "%...%" will be replaced with the parameter value. Or even cooler, look for new "bind" feature here: https://knpuniversity.com/s...
Cheers!
"Houston: no signs of life"
Start the conversation!