Meet our Tiny App + PhpStorm Setup

Video not working?

It looks like your browser may not support the H264 codec. If you're using Linux, try a different browser or try installing the gstreamer0.10-ffmpeg gstreamer0.10-plugins-good packages.

Thanks! This saves us from needing to use Flash or encode videos in multiple formats. And that let's us get back to making more videos :). But as always, please feel free to message us.

One of my main goals in these tutorials will be to help you really understand how Symfony - how your application - works.

To start with that, let's take a quick look at the directory structure.

The public/ Directory

There are only three directories you need to think about. First, public/ is the document root: so it will hold all files that need to be accessible by a browser. And... there's only one right now: index.php:

28 lines public/index.php
... lines 1 - 2
use App\Kernel;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request;
require dirname(__DIR__).'/config/bootstrap.php';
if ($_SERVER['APP_DEBUG']) {
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$kernel->terminate($request, $response);

This is called the "front controller": a fancy word that programmers invented to mean that this is the file that's executed by your web server.

But, really, other than putting CSS or image files into public/, you'll almost never need to think about it.

src/ and config/

So... I kinda lied. There are truly only two directories that you need to think about: config/ and src/. config/ holds... um... puppies? No, config/ holds config files and src/ is where all your PHP code will go. It's just that simple.

Where is Symfony? Our project started with a composer.json:

66 lines composer.json
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.2.5",
"ext-ctype": "*",
"ext-iconv": "*",
"symfony/console": "5.0.*",
"symfony/dotenv": "5.0.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "5.0.*",
"symfony/yaml": "5.0.*"
"require-dev": {
... lines 16 - 64

file, which lists all the third-party libraries that our app requires. Behind the scenes, that symfony new command used composer to install these... which is a fancy way of saying that Composer downloaded a bunch of libraries into the vendor/ directory... including Symfony itself.

We'll talk more about the other files and directories along the way... but they're not important yet.

Using the symfony Local Web Server

A few minutes ago, we used PHP itself to start a local web server. Cool. But hit Ctrl+C to quit that. Why? Because that handy symfony binary tool we installed comes with a more powerful local server. Run:

symfony serve

That's it. The first time you run this, it may ask you about installing a certificate. That's optional. If you do install it - I did - it will start the web server with https. Yep, you get https locally with zero config.

Once it's running, move over to your browser and refresh. It works! And the little lock icon proves that we're now using https.

To stop the web server, just hit Control + C. You can see all of this command's options by running:

symfony serve --help

Like ways to control the port number. When I use this command, I usually run:

symfony serve -d

The -d means to run as a daemon. It does the exact same thing except that now it runs in the background... which means I can still use this terminal. Running:

symfony server:status

Shows me that the server is running and:

symfony server:stop

Will stop it. Let's start it again:

symfony serve -d

Installing PhpStorm Plugins

Ok: we're about to start doing a lot of coding... so I want to make sure your editor is ready to go. And, yea, you can use whatever editor your want. But I highly recommend PhpStorm! Seriously, it makes developing in Symfony a dream! And no, the nice people at PhpStorm aren't paying me to say this... though... they do actually sponsor several open source PHP devs... which is kinda better.

To really make PhpStorm awesome, you need to do two things. First, open the Preferences, select "Plugins" and click "Marketplace". Search for "Symfony".

This plugin is amazing... proven by the nearly 4 million downloads. This will give us all kinds of extra auto-completion & intelligence for Symfony. If you don't have it already, install it. You should also install the "PHP Annotations" and "PHP toolbox" plugins. If you search for "php toolbox"... you can see all three of them. Install them and restart PhpStorm.

Once you've restarted, go back to Preferences and Search for Symfony. In addition to installing the plugin, you also need to enable it on a project-by-project basis. Check Enable and then apply. It says you need to restart PhpStorm... but I don't think that's true.

The second thing you need to do in PhpStorm is to search for Composer and find the "Languages and Frameworks", "PHP", "Composer" section. Make sure the "Synchronize IDE settings with composer.json" box is checked... which automatically configures several useful things.

Hit "Ok" and... we are ready! Let's create our very first page and see what Symfony is all about, next.

Leave a comment!

  • 2020-06-23 Victor Bocharsky

    Hey Shayma,

    Great! Thanks for confirming that it works for you now ;)


  • 2020-06-22 Shayma

    Hey Victor,

    Thanks a lot!! You really helped me out. It's working now. I appreciate your help.


  • 2020-06-22 Victor Bocharsky

    Hey Shayma,

    The better would be to run the project on Symfony web server instead of running built-in PHP web server as you do. If you have symfony binary installed - you just need to run:

    $ symfony serve

    And it will run the website, then just follow the link in the output.

    But in case you want to run the website with PHP built-in web server - looks like the error is pretty obvious, it says the public/ folder does not exist. I suppose you created a new project, but then you should go into the project directory. I.e. after you executed "symfony new my-new-project" Symfony binary created a "my-new-project" folder, so you need to change directory to it, i.e. execute "cd my-new-project" and only then run that "php -s -t public/". When you're in your "my-new-project" directory, to make sure you have public/ folder - you can run "ls public/" command in your terminal.

    I hope this helps!

    About "check:req" output: if those are just warnings/recommendations - you can completely ignore them for now, the project should run well. But it's recommend to do for production when you will deploy your application for real users. Google how to install PHP accelerator or how to tweak that php.ini config for your OS - it may be different for different OS.


  • 2020-06-20 Shayma


    Thanks! it's worked when i put my real email. but now i have another issue :( sorry to bothering you!

    it says when i run php -s -t public/: Directory public/ does not exist.

    And when i do the check:req, it's says that's ok but php need to be installed:

    a PHP accelerator should be installed
    > Install and/or enable a PHP accelerator (highly recommended).

    * realpath_cache_size should be at least 5M in php.ini
    > Setting "realpath_cache_size" to e.g. "5242880" or "5M" in
    > php.ini* may improve performance on Windows significantly in some
    > cases

    Can you tell me how to solve this problem?

  • 2020-06-19 weaverryan

    Hey @Shayma!

    Ah! That's not a very clear error :). It looks like you're using git for the first time on this system. Try this:

    A) Run those 2 comments that it mentioned (the 2 git config commands) but you use real email and name.
    B) Re-run the symfony new</command>

    When you first use git on a machine, it asks you to set your name & email. It does this so that when you make any commits, it can use your email and name for those commits. The symfony new command failed because it tries to setup a git repository for you, but those 2 settings weren't there yet.

    Let me know if that helps!


  • 2020-06-19 Shayma

    Thank you to help me, i actually repeat everything from the beginning but i have this error:
    What is that supposed to mean?

    Setting up the project under Git version control
    (running git init C:\Users\shaym\cauldron_overflow)

    *** Please tell me who you are.


    git config --global ""
    git config --global "Your Name"

    to set your account's default identity.
    Omit --global to set the identity only in this repository.

    fatal: unable to auto-detect email address (got 'shaym@LAPTOP-8877L5EN.(none)')

    exit status 128

  • 2020-06-19 Diego Aguiar

    Hey @Shayma

    You need to run symfony server:ca:install to install a local SSL certificate, then you will be able to run your project through https locally


  • 2020-06-18 Shayma

    Hi, i didn't get the https in the command. it is only http. that's means it's not secure.
    What can i do to fix that problem?

    [OK] Web server listening

  • 2020-06-18 weaverryan

    Ah... good catch! Thanks for letting me know - I'll put that on my "list of things that might be preventing auto-complete" to think about!


  • 2020-06-16 Samuel Sekegor

    I've seen my mistake.

    I always write response with a lowercase r instead of uppercase like so: ' Response'

    Your response time is impressive.
    Thank you very much.

  • 2020-06-16 Samuel Sekegor

    1. Yes, the code works when I manually input the use statement.

    2. I open the the entire symfony folder.

  • 2020-06-16 weaverryan

    Hey Samuel Sekegor!

    > My php storm is not bringing out the full prediction when I'm typing
    > Return new response

    Hmmm. This is one of the most basic features that PhpStorm gives you, so it definitely makes me think something is wrong. Two questions:

    1) Does the code work? If you add the use statement and type all the code, does it work? That will help answer the question of whether or not all the vendor code is installed correctly.

    2) How did you open PhpStorm? I usually go to "File -> Open" and select my entire Symfony directory. After you do this, you should see all the folders - like config/, src/ and public/ - on the left tree. If you somehow only opened a *specific* file (not the entire directory), then you would probably not get auto-complete.

    > I also noticed that your initial command (symfony new cauldron_overflow) is not working

    Hmm, did you get an error when you ran this? Do you remember what the error was?

    Don't worry, I'm sure we'll figure out what's going on :).


  • 2020-06-16 Samuel Sekegor

    My php storm is not bringing out the full prediction when I'm typing
    Return new response...

    Hence its unable to auto complete the use symfony\component\httpfoundation\response;

    Is the problem with the php storm or my installations, I'm using windows and I also noticed that your initial command (symfony new cauldron_overflow) is not working.

  • 2020-05-13 Vladimir Sadicov

    Hey Chris Crooke

    Looks like your browser forgot about symfony ssl certificate! Try to run symfony server:ca:install and follow instructions of course you will need to restart server/browser etc... If it still not helps, you can also try another browser, just to be sure that it is a global problem or browser related!


  • 2020-05-12 Chris Crooke

    After running symfony serve -d I'm getting a privacy warning in the browser ('Your connection is not private') and my terminal is showing:

    WARNING unable to find the application log
    2020/05/12 14:25:20 http: TLS handshake error from remote error: tls: unknown certificate
    2020/05/12 14:25:20 http: TLS handshake error from remote error: tls: unknown certificate
    2020/05/12 14:25:20 http: TLS handshake error from remote error: tls: unknown certificate
    2020/05/12 14:25:20 http: TLS handshake error from remote error: tls: unknown certificate
    2020/05/12 14:25:30 http: TLS handshake error from remote error: tls: unknown certificate
    2020/05/12 14:25:33 http: TLS handshake error from remote error: tls: unknown certificate
    2020/05/12 14:25:33 http: TLS handshake error from remote error: tls: unknown certificate
    2020/05/12 14:26:00 http: TLS handshake error from EOF
    ^CMay 12 14:26:08 |INFO | SERVER shutting down
    May 12 14:26:08 |DEBUG| PHP stopped path="/usr/bin/php7.2" php="7.2.24"
    May 12 14:26:08 |INFO | SERVER shut down, bye!

    It was working when I completed this chapter but after creating the QuestionController in chapter 3 I started getting the above issues. Any help is appreciated

  • 2020-03-14 weaverryan

    Yea, it's just not a feature I use - I believe you only need to configure the Composer binary if you want to allow PhpStorm to run the composer commands for you. I don't use that feature - but if you do, you'll definitely want to configure that :).


  • 2020-03-10 Diego Aguiar

    Hey Кирило Хацько

    Ha! nice catch! But anyway, it's not important to have it installed for this tutorial


  • 2020-03-10 Кирило Хацько

    You did not get composer plugin set up.
    You even can see phpstorm warning on video.

  • 2020-03-09 Diego Aguiar

    Hey maxii123

    Oh, that must be a Chrome thing, thanks for sharing it with others :)

  • 2020-03-09 maxii123

    Just for the record: Installed the certificate, run server serve. Get a security warning still though. You need to ensure you restart the google chrome process.