Our Micro-App & PhpStorm Setup

Our mission: to boldly go where no one has gone before... by checking out our app! I already opened the new directory in PhpStorm, so fire up your tricorder and let's explore!

The public/ Directory

There are only three directories you need to think about. First, public/ is the document root: so it will hold all publicly accessible files. And... there's just one right now! index.php. This is the "front controller": a fancy word programmers invented that means that this is the file that's executed when you go to any URL.

But, really, you'll almost never need to worry about it. In fact, now that we've talked about this directory, stop thinking about it!

src/ and config/

Yea, I lied! There are truly only two directories you need to think about: config/ and src/. config/ holds... um... ya know... config files and src/ is where you'll put all your PHP code. It's just that simple.

Where is Symfony? As usual, when we created the project, Composer read our composer.json file and downloaded all the third-party libraries - including parts of Symfony - into the vendor/ directory.

Installing the Server

Go back to your terminal and find the original tab. Check this out: at the bottom, it says that we can get a better web server by running composer require server. I like better stuff! So let's try it! Press Ctrl+C to stop the existing server, and then run:

composer require server

If you're familiar with Composer... that package name should look funny! Really, wrong! Normally, every package name is "something" slash "something", like symfony/console. So... server just should not work! But it does! This is part of a cool new system called Flex. More about that soon!

When this finishes, you can now run:

./bin/console server:run

This does basically the same thing as before... but the command is shorter. And when we refresh, it still works!

By the way, this bin/console command is going to be our new robot side-kick. But it's not magic: our project has a bin/ directory with a console file inside. Windows users should say php bin/console... because it's just a PHP file.

So, what amazing things can this bin/console robot do? Find your open terminal tab and just run:


Yes! This is a list of all of the bin/console commands. Some of these are debugging gold. We'll talk about them along the way!

PhpStorm Setup

Ok, we are almost ready to start coding! But we need talk about our spaceship, I mean, editor! Look, you can use whatever your want... but... I highly recommend PhpStorm! Seriously, it makes developing in Symfony a dream! And no, those nice guys & gals at PhpStorm aren't paying me to say this... but they can if the want to!

Ahem, If you do use it... which would be awesome for you... there are 2 secrets you need to know to trick out your spaceship, ah, editor! Clearly I was in hyper-sleep too long.

Go to Preferences, Plugins, then click "Browse Repositories". There are 3 must-have plugins. Search for "Symfony". First: the "Symfony Plugin". It has over 2 million downloads for a reason: it will give you tons of ridiculous auto-completion. You should also download "PHP Annotations" and "PHP Toolbox". I already have them installed. If you don't, you'll see an "Install" button right at the top of the description. Install those and restart PHPStorm.

Then, come back to Preferences, search for "symfony" and find the new "Symfony" section. Click the "Enable Plugin" checkbox: you need to enable the Symfony plugin for each project. It says you need to restart... but I think that's lie. It's space! What could go wrong?

So that's PhpStorm trick #1. For the second, search "Composer" and click on the "Composer" section. Click to browse for the "Path to composer.json" and select the one in our project. I'm not sure why this isn't automatic... but whatever! Thanks to this, PhpStorm will make it easier to create classes in src/. You'll see this really soon.

Okay! Our project is set up and it's already working. Let's start building some pages and discovering more cool things about new app.

Leave a comment!

  • 2018-01-16 kribo

    Cool cannot wait ...

  • 2018-01-16 Diego Aguiar

    Hey kribo

    We published chapter 6 today! And we publish a new chapter every day, so, by tomorrow you should be able to watch chapter 7 :)

    Have a nice day

  • 2018-01-15 kribo

    Victor Bocharsky
    hi thnx for the response.
    Any idea when the other vids 6,7 & 8 will be published?

  • 2018-01-15 Victor Bocharsky

    Hey kribo ,

    Glad you got it! Really, just add "php ./bin/console" for all Symfony commands. It's due to different file system. Mac OS and Linux based OS like Ubuntu are Unix based platforms, but Windows is not. bin/console is just a PHP file, so to run any PHP file on Windows you always need to run it though php interpreter.


  • 2018-01-14 kribo

    Hi there,
    First off finally found a Symfony 4 course in English that makes sense.
    But came across my first issue.
    I installed the composer require server and in the video you run the command "./bin/console server:run" to execute.
    This doesn't work for me. Is it because I'm on a Win10 using Visual Studio Code internal Terminal?
    I always have to add php to my console commands.? "php bin/console server:run"
    DO you know why?

    Ok my bad ... Watch the vid might help....lol
    But why the php for win users ?

  • 2018-01-11 niumis

    Thank you, Victor Bocharsky!

  • 2018-01-11 Victor Bocharsky

    Hey niumis.

    Good catch! Actually, those are not important for us yet. Well, app is matched so no changes are needed, however we don't have translations so we can miss it. What about Web Dir - yeah, it should be set to "public" for Symfony 4 applications, but as I said it's not important for us so far. It helps with assets, i.e. provide autocompletion for files inside of "public/" directory. So, you may tweak this value in advance or leave it for later.


  • 2018-01-10 weaverryan

    I think we should add a note about this - the fact that it's being ignored (and that you should ignore it too!). I'll open an issue about that!

  • 2018-01-10 niumis

    Hi @weaverryan

    In PhpStom's Symfony Plugin no need set 'Translation Root Path', 'App Directory' and 'Web Directory' paths?

  • 2018-01-09 J.R. Jenkins

    Diego Aguiar, those are my thoughts personally as well. I snooped around the project directory a little, and it looks like among other information it records which plugins are active, so I am sure there are some benefits. But I like the idea of "taking ownership" of making sure my IDE is doing what I want it to do, so I think I will continue to exclude the directory as well. Thank you!

  • 2018-01-09 Diego Aguiar

    Hey J.R. Jenkins

    Here at KnpU we exclude entirely that directory, as far as I know it only contains metadata used by your PhpStorm and it's plugins. I believe a project should be agnostic from the IDE that you or any other uses for developing, if not, you would end up with many folders unrelated to the application itself.


  • 2018-01-09 J.R. Jenkins

    So I am curious about how much of PHPStorm's .idea directory you allow into your normal projects VCS? I have looked at their online documentation to this effect, but I seemed to find contradictory opinions between the developers and users. I have never understood what is in this directory that I would definitely *want* to be included, at least as far as my Symfony projects go. So I usually just have the .idea directory in my global gitignore file to block it all, but this doesn't help other users that might check the project out, and I am sure I am missing out on some functionality by doing this. Do you all have a recommendation?