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 they 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!

  • 2019-02-27 Victor Bocharsky

    Hey Hugo,

    Hm, ok, let me clarify the steps you have done so far. You created the project with "composer create-project symfony/skeleton the_spacebar", then changed your current directory to the project with "cd the_spacebar" and inside that directory executed "composer require server". But when you run "bin/console server:run" it starts the web server and show you what URL you can use to access it, i.e.

    You don't see any errors in the console output after you run the web server? Try to go to again wait until you see the error and check console output again. Do you have any new lines there? Any errors? Server write logs into the console as its output, so you may find a problem there.

    Though your problem seems like something is blocking the request, probably system ask you allowing new connections with some kind of popup and you didn't allow access or miss that popup? Probably you have an antivirus system that might block this connection? Btw, are you on Windows OS? Could you try to turn your antivirus off completely and try again? Also, I'd suggest you to completely restart your computer before start doing anything that I advised you in this comment.

    Let me know if it helps. Also, if it's still does not work, please, could you paste in your next comment the full output of the server:run command you have in your console after a few timeout requests in the browser.


  • 2019-02-25 Hugo Peña

    Hi, thank you for your prompt response. Sorry I didn´t clarify that I haven't code anything, I'm just following the tutorial, I install de composer server, initialize it, but when I open the browser I try to load localhost:8000, I'm getting the error message.

  • 2019-02-25 Victor Bocharsky

    Hey Hugo,

    It sounds like your script was executing too long, longer than 30 seconds. If you think it's on purpose, i.e. if you write a script that processes a lot of data - then you probably need to increase maximum execution time in php.ini or make your script wiser, like process only a part of big data at once. But if you're trying to load a regular page - it's no good, probably something is broken in your code, maybe you have a recursion? You can try to install xdebug and try again. Or something is broken in your environment configuration.

    Could you explain a bit more? Are you talking about the code you downloaded from this course? Are you in start/ or finish/ folders? What page exactly are you trying to load? Is it homepage, i.e. ?


  • 2019-02-22 Hugo Peña

    After installing the composer server, it says it´s running

    [OK] Server listening on

    But, when openning the web page, i´m getting the following error:

    Whoops, looks like something went wrong.
    (1/1) FatalErrorException
    Error: Maximum execution time of 30 seconds exceeded

    in Router.php line 34

  • 2019-02-08 Hessuss Hesiu Kowalski

    Hi, great job, nice and funny narration, and most importantly - a huge package of valuable knowledge.

  • 2018-11-15 Vladimir Sadicov

    Hi siddhartha

    It looks like you need to install Symfony plugin. You can do it in "Settings->Plugins" type "Symfony plugin" in search field, and click "install" after restart PhpStorm, and now it should work


  • 2018-11-15 siddhartha

    hi ,
    there is no symfony in language&frameworks->php
    please help
    its in language&frameworks->PHP

  • 2018-11-12 Diego Aguiar

    Ohh so your Antivirus was interfering with the script that starts the web server? Anyways, thanks for sharing your solution!


  • 2018-11-12 Adriel Werlich

    I solved using this reference, in case anyone need ->

    Solved by :

    Delete symfony folder in vendor

    composer update

    If you have antivirus (like Avast) disable it before launching web server

    php bin/console server:run

  • 2018-11-12 Adriel Werlich

    hello there, I´m getting some error message when opening the web page, just after creating and running the server right on the start -->

    Fatal error: Unknown: Failed opening required 'D:\nprojetos\composer\the_spacebar\vendor\symfony\web-server-bundle/Resources/router.php' (include_path='C:\xampp_\php\PEAR') in Unknown on line 0

    Does anyone know what this is about?

  • 2018-11-11 weaverryan

    Hey @Hunter Baba!

    Hmm. That is super strange! The server:run command is basically a wrapper around running the php -s command. But, if the other command is working for you, you can safely just use that. The server:run command mostly exists as a shortcut.


  • 2018-11-10 Hunter Baba

    it still fails. If i run php -S -t public then its working..
    I have console file also in bin folder.
    when i run {{ php bin/console server:run }} then in CLI OK server listening on is coming but in browser its not coming

  • 2018-11-09 Vladimir Sadicov

    Hello Hunter Baba

    Please check command you trying to run. it should be like

    php bin/console server:run

    If it still fails, check if you have file "console" in "bin\" folder and reply here


  • 2018-11-09 Hunter Baba

    .bin/console server:run is saying could not open file error. Help ASAP.

  • 2018-10-09 Argon

    Why dont you colorised command line greeting? I mean `~/path/file$`. It would be easier to find this lines if they would be colored differently.

  • 2018-10-01 Victor Bocharsky

    Hey Roberto,

    Good question! I just always keep app/ as a value for the "app directory" for both Symfony 3 and 4. Though not sure for what exactly this value is used in this plugin :)


  • 2018-10-01 Roberto Briones Argüelles

    Which is the correct value for "App Directory" in the Symfony Plugin configuration for Symfony 3 or 4? Since in the video you doesn't change the default values. I know that for "Web directory" the value should be "public" but not sure what should be instead of "app" in "App Directory".

  • 2018-08-27 Victor Bocharsky

    Hey Lyndonjohn,

    Looks like it works for you now. Yeah, pulling symfony/symfony with all its deps may take some time. Btw, if we're talking about Symfony 4, i.e. symfony/skeleton - you should avoid symfony/symfony dependency and specify other minor deps explicitly because it causes conflict on this package, see: https://github.com/symfony/...


  • 2018-08-25 Lyndonjohn

    It's ok now. It just took too long to long..

  • 2018-08-25 Lyndonjohn

    Got stuck at Restricting packages listed in "symfony/symfony" to "4.1.*" after running composer require server. Please help.

  • 2018-05-29 Victor Bocharsky

    Hey Viktor,

    Yes, you're correct! On Windows OS you need to pass this command through PHP interpreter manually. Glad you had found the solution faster than we replied to you! And thanks for sharing it with others.


  • 2018-05-29 Viktor

    okey, I`ve found a way. If anyone else need - just type
    PHP bin/console server:run

  • 2018-05-29 Viktor

    Hey, can anyone tell me how to run this command on Windows Open Server?
    ./bin/console server:run

  • 2018-03-28 Diego Aguiar

    Totes! it is 1000x better than Dreamweaver (I started coding on Dreamweaver... shame on me)

    I hope you could get your composer installation up and running. Cheers!

  • 2018-03-28 Carlo Mario Chierotti

    Hello Diego,

    yes, I mean setup composer non PhpStorm (btw, this editor is AWESOME).

    thank you for your time


  • 2018-03-27 Diego Aguiar

    Hey Carlo Mario Chierotti

    Do you mean setup composer on PhpStorm? If that's the case you would have to install composer as well on your "Host" machine


  • 2018-03-27 Carlo Mario Chierotti

    hello Ryan,

    I am on a Mac but in my development setup I prefer run the project in an Ubuntu 16.04 VM (with Vagrant and Virtual Box) and I wonder if I can still setup composer as you show in the video.

    thanks a lot for your help


  • 2018-03-22 Victor Bocharsky

    Hey Billy,

    Ah, ok, so you need to upgrade your PHP version somehow to 7.1.3 at least if you want to run Symfony 4. I also on a Mac, and I installed my PHP version with Homebrew, see https://github.com/Homebrew... if it helps you. Otherwise, I think you can google for some post about how to install/upgrade PHP on your Mac.


  • 2018-03-21 Billy Thomas

    I get 7.2.2 when I run from a new terminal window but in my repo directory i get
    `PHP 5.5.38 (cli) (built: Oct 29 2017 20:49:07)

    Copyright (c) 1997-2015 The PHP Group

    Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies`
    I tried to update to 7.2 earlier but I guess it didn't work. Im on a Mac OS X 10.11.6 el capitan if that helps with anything

    EDIT: I opened a new terminal window and ran php -v still got 5.5.38

  • 2018-03-21 weaverryan

    Hey Billy Thomas!

    Hmm, interesting! I do have a theory: you may be using an out-dated PHP version. Symfony 4 requires PHP 7.1, so if you're using something lower, then those files would appear to have syntax errors for that PHP version. What do you see when you run:

    php -v

    If it's below 7.1.3, then get that guy upgraded :). Let us know!


  • 2018-03-21 Billy Thomas


    Im getting parse errors in both bin/console and public/php.index
    I haven't touch either of those files, but they seem to be keeping me from running the server with either `./bin/console server:run` or `php -S -t public`
    Anyone run into something like this?

  • 2018-03-15 zomars

    It's working now. Thanks!

  • 2018-03-15 Diego Aguiar

    Hey zomars

    Are you still having this problem? If so, could you tell me what operation system are you using and what browser


  • 2018-03-15 zomars

    Im getting this error: "The media could not be loaded, either because the server or network failed or because the format is not supported."

  • 2018-02-12 Victor Bocharsky

    Hey Juraj,

    index.php *is* the front controller if we're talking about Symfony 4, in Symfony 3.x there were a few front controllers: app.php, app_dev.php, etc.

    Btw, the error on the screenshot you sent is Symfony error, so it means the request was handled by Symfony (i.e. request got your front controller whether it was index.php or app.php, etc.), but the route "/cart" was not found. And there could be several reasons, if you're sure you have "/cart" route, try to clear the cache first.


  • 2018-02-11 Juraj Pecháč

    index.php is not the "front controller".

  • 2018-01-30 Diego Aguiar

    Hey Robertino Vasilescu

    Ohh, so that's a new feature of newest PhpStorm version? I haven't upgraded mine yet :p


  • 2018-01-30 Robertino Vasilescu

    On my PhpStorm 2017.3.3 the composer.json was automatically found and loaded :-)

  • 2018-01-29 shing


  • 2018-01-29 weaverryan

    Hey shing!

    Ah, cool! So, another good question :). Obviously, making a bundle is still the right way to do it. Of course, as you already know, eventually you'll probably want to make it a proper package that lives in vendor. But, that's annoying at first when you're building it inside the first project. So, you *can* still put it in src/, you just need to create a second psr-4 autoload rule for it. Actually, I have an example of this: https://knpuniversity.com/s.... In that case, we load up AppBundle from src AND still load the normal App\ stuff. So, put whatever extra autoloading rules you need for your bundle in src, and then make sure your normal autoload rule is last . And... don't forget to run composer dump-autoload after making the change ;).

    And thanks for your nice words! That just made my Sunday :). Keep up the good stuff yourself!


  • 2018-01-26 shing

    This is awesome! Makes sense. I have a couple of "folders/packages" that I made, for example comment,like system that I like to re-use on other new symfony projects and make kinda portable. Is making a 'bundle' outside src/ a recommended way? What is good ghetto way of dealing with portable "packages/bundles/folders".

    Thxs again. Knp is the reason I'm using symfony and have been a long time paying subscriber. Keep up the good stuff!

  • 2018-01-25 weaverryan

    Hey shing!

    Great question :). And... no! In Symfony 4, you never create or have a bundle in your app (you of course still install third-party bundles, but no bundles in src). The reason we didn't make this change until Symfony 4 (we could have done it in Symfony 3), was that many bundles and commands didn't work well with a "bundless" system. But, that's not true anymore (with a few exceptions).

    About organization, here's what I recommend (and this has been verified by some friends of mine who've worked on GIANT apps): if you want to organize things further, do it like this:

    * src/Controller/Admin/*.php
    * src/Controller/Frontend/*.php

    Basically, create traditional directories in src/, but then create sub-directories inside those. I think this is already what you're trying to do, based on your comment :). You're correct that the MakerBundle doesn't support sub-directories like this yet, but it will soon. Until then, you can move the files - but you won't need to do that forever :).


  • 2018-01-24 shing

    Hi, In symfony 4, do we still have a bundle or folder structure? Like src/<folder>/controller/<classname>.php ? bin/console make:controller or the others like make:entities dont seems to support other folders and only generates file in src. How would you go about organising different parts of the app? Thanks in advance

  • 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?