Scroll down to the script below, click on any sentence (including terminal blocks!) to jump to that spot in the video!Cool, got it! Show me the script!
Well hey guys! Symfony 3 is around the corner, ah, or maybe even released if you're watching this later! Hello from the past!
Anyways, it's time to talk about all the new cool shiny stuff. But first, I have a confession: Symfony 3 doesn't have any new features. Not even 1... and this is amazing. Seriously, Symfony is paving the way towards a new paradigm of upgrading. I'll talk about upgrading later. But in a nut shell, it means that you'll be able to upgrade to Symfony 3 without rewriting your code and breaking everything.
When Symfony 3 is released, Symfony 2.8 will be released at the same time and both versions will have the same features. That means that if you upgrade to 2.8, you'll get all the good new stuff. So what's new in Symfony 3? Nothing! But there are a lot of new great features in 2.8, and I'll tell you about them.
But wait! There is one thing that's new specifically in Symfony 3: the new Symfony 3 directory structure. You can see it in my editor. If you're an experienced user, it's not a big change.
app/logs directories have been moved to a new
bootstrap.php.cache file also got moved here from
Second, we all know and love
app/console. Well, that's now
As a result, the
app/ directory is now just configuration code: stuff that we
can actually modify. All the things we don't normally need to worry about editing -
like the cache and
console file - are out of the way. This gives
app/ a new focus.
If you're using PhpStorm with the Symfony plugin, you'll need to change a couple
of settings so that it knows to look in the
var/ directory for a few cache files.
You may not need to do this in the future - but double-check it.
So, how can we upgrade our project from the old structure to this one? And do we need to change our project?
Actually, no: this new structure has always been possible. In fact, open up
The only reason the new structure works is because the
methods have been overridden:
|... lines 1 - 5|
|class AppKernel extends Kernel|
|... lines 8 - 36|
|public function getCacheDir()|
|public function getLogDir()|
|... lines 46 - 50|
If you don't override these, they default to using
logs/ in this
So in your project, if you override these then... boom! You're using the new directory
structure. Well, you'll also want to move the
console file and a few other things.
I'll talk about upgrading later.
And if you don't want to use the new directory structure... then boom! Don't use
it. You're free to organize things however you want. Just be aware that the Symfony
documentation will be reference things like the
you'll need to translate to what that means in your app.
There are two other tiny changes: the
tests directory has been moved out of
into the root of the project:
|... lines 1 - 2|
|... lines 4 - 6|
|class DefaultControllerTest extends WebTestCase|
|... lines 9 - 17|
phpunit.xml.dist also now lives in the root directory. That means no more
phpunit -c app: just run
and it'll find the configuration file automatically.
That's it for the new directory structure, you can start using it right now, or leave your project alone.