I’m not a big fan of the typical
app_dev.php setup in the Symfony Standard Edition. While it’s not a big deal if the
app_dev.php file gets deployed, it shouldn’t be done anyway. It’s too risky and complicates the deploy process a bit.
The alternative: environment variables that default to production mode.
Create a Named Constructor on AppKernel
Rather than doing
new AppKernel('prod', false) in a single
index.php entrypoint, we’ll create a named constructor that fetches a few environment variables. The key here is to default to production mode so a botched deployment doesn’t ever expose debug information.
One Entrypoint to Rule Them All
Now use that named constructor as your main entrypoint —
app.php in Symfony standard, though I like to just use
index.php. And remove the
To me, this method is easier to understand and removes a step from the deployment. Two fairly good things.
Image credit Flickr