Hey guys! If you've watched even one video on KnpU - please tell me that you have - then you've seen me using PHPStorm.

Now think about how much you use your editor. If you work 40 hours a week I bet you stare deeply into your editor at least 20 of those hours. So over a year, that's... let's see here - carry the one - over 1,000 hours!

So if you could learn something that saves you a few seconds now, that's going to mean you're saving 10's of hours in the future.

Particularly in Symfony development, mastering PHPStorm is going to completely speed up the way you develop and help you catch mistakes you may have missed otherwise.

If you've never used PHPStorm before it does have a free trial period that you can use to see if it's going to work for you.

Go Deeper!

For even deeper information about PhpStorm settings and shortcuts, you can also check out Beginner's Guide to PhpStorm - Tips & Tricks.

UI Updates

I'm working with a fresh version of PHPStorm, this is not how I want my development environment to look - all this white is stressing me out. So download your own copy and let's customize this thing together.

If I open any of my files right now you'll see that they look pretty ugly. Let's clean that up first: open up preferences and in Appearance under Appearance & Behavior you can select your theme, change that to Darcula.

(insert Dracular slow laugh here)

This is the theme of the UI which also goes and sets the scheme for the editor. And this is already so much better. Staring into a white screen for 1,000+ hours a year is very similar to just staring at a lightbulb -- not so great on the eyes.

Speaking of eyes, I'd like to see my font size a bit bigger here. Back to preferences, on a mac its shortcut is ⌘, so I'll start using that. On Windows and Linux, it's the longer Ctrl+Alt+S - you can check out the key mappings under the keymap section, to see and simplify these.

Use this search to look for font. This pulls up a few things, general appearance, colors & fonts. Let's pick font here and there's font size.

I can't immediately change the font size I've got because that would change the Darcula scheme. So first let's click 'save as' so we can customize this, save it as 'darcula mine'. And now I can change the font size to 14 and give it a line spacing of say 1.2. Ahh so much better.

Project Organization

Over here on the left, you can see the tuts and knpu directories. I use these to help me build this tutorial - but when I'm coding, I don't want to see them. Any time you have a directory that you don't want PHPStorm to look into, or that you just don't want to see, you can hide it. Right click tuts, find 'mark directory as' and select 'excluded'. In a second that will hide this for me. Let's also do this on the knpu directory.

And now we can change the view in the upper left from 'project' to 'project files'. Let's also exclude this .idea directory. If you ever need to see those in the tree again you can just switch back to 'project' and they'll reappear. Then you can even unmark them if you want to.

Plugins

Okay back to the 'project files' view. So PHPStorm is the best editor I've ever seen. But the real power with Symfony comes from an amazing plugin. Back in preferences if you search for Symfony it brings you to a plugin spot. Click 'Browse Repositories', here you see the community plugins for Symfony and there's one called the 'Symfony 2 Plugin'. To prove how great it is just look at its 1.2 million downloads. So press the 'Install Plugin' button to get this added to our IDE.

The other plugin that you are definitely going to want to install is this called 'PHP Annotations'. Find that one in the search and install it. Perfect.

Close out of this window, and then press ok and restart PHPStorm.

You only need to install the Symfony plugin once, but each time you start a new project you will need to enable it. Back in preferences, search Symfony and check the 'Enable Plugin for this Project' checkbox. Do that just one time per project - not bad!

The checkbox had a note that it requires a restart, that's mostly not true. But I am going to restart one more time because there are a few small features that will not work until you do this.

Now we're really ready to go! I've already got my my site running on localhost:8000 and we've got a nice looking 404 page since there isn't anything inside of here yet.

Just to prove that the Symfony Plugin is installed and running, in the bottom right of PHPStorm you should see a little Symfony menu. Clicking it gives you a quick way to jump into the profiler for any recent requests.

Now that our editor is all setup let's get down to work!

Leave a comment!

  • 2016-08-17 Victor Bocharsky

    Hey Egor,

    Did you activate Symfony plugin for project? Most probably you didn't. You can activate it in "Preferences" => "Languages and Frameworks" => "PHP" => "Symfony" and check "Enable Plugin..." item. Also ensure you have correct paths there and don't forget to restart PhpStorm.

    Cheers!

  • 2016-08-17 Egor Ushakov

    Latest Symphony plugin is installed on PhpStorm 2016.2 and there is no right-bottom-corner Symfony menu. Something changed from Symfony 2 version or I just wrong at plugin installation?

  • 2016-06-20 Victor Bocharsky

    Ah, that's great! I love licences which include free upgrades for major versions.

    Happy coding with your new PhpStorm! ;)

  • 2016-06-17 Grzegorz Szaliński

    I went to my JetBrains account and realized that my license is valid with version 9. Doh. The excluded folders are shown correctly in v9. Thanks Victor :)

  • 2016-06-17 Victor Bocharsky

    Hey, Grzegorz!

    It's weird, I also don't see excluded folder in "Project Files" scope, but see it in "Project".

    Probably your PhpStorm version handle excluded folders a little differently as mine. I can only suggest you update PhpStorm to the latest version, if you can. It should helps.

    Cheers!

  • 2016-06-17 Grzegorz Szaliński

    Hello,
    I'm having a problem with Excluded folders view in Project tool window - they're not shown. Neither in Project scope, nor in Project Files scope. In your screencast the excluded folders are marked red in the Project scope. In mine PhpStorm they're not visible at all. I'm using PhpStorm 7.1.5. Can it be the feature is not present in my version?
    Btw, when I go to Settings / Directories, the excluded folders are listed along with the nice red folder icon. Also, directories marked as Resources Root are listed in the Project scope with blue folder icon.
    Thanks

  • 2016-06-13 JLChafardet

    Im starting to feel the worth for the subscription haha, this screencasts are really good.

  • 2016-04-05 weaverryan

    Ah, cool! That's a good thing... since it works for Symfony 2 & 3 :).

  • 2016-04-02 Kaizoku

    Seems that the Symfony2 plugin have been renamed to Symfony.

  • 2015-11-11 WEB BY DOUG

    Thank you so very much. Still having issues. Think it would be good to start with course referenced. Kind regards,

  • 2015-11-09 weaverryan

    Hey again!

    Ah, welcome! Thanks for giving me your background - that's very helpful. I'm the opposite - a guy with a ton of Symfony experience, but I'm still learning Drupal 8, so I know how it is :).

    To fix this issue, you need to install your vendors via composer. I realize that we need to do a better job with the setup README instructions - sometimes I assume that certain tutorials are only watched by devs with a bunch of Symfony experience already :). Anyways, here is a good README: https://github.com/knpuniversi.... You don't think you'll need to do the Doctrine database steps - so you can skip those (but are free to do them if you want).

    For starting with Symfony, I'd recommend starting here: http://knpuniversity.com/scree.... The tutorials are not perfectly up to date, but it's the best place to start (and we're updating them right now!).

    Cheers!

  • 2015-11-09 WEB BY DOUG

    Hello,

    I ran "php app/console server:run" from start directory and got this error:

    "Warning: require_once(/Users/dougouverson/Sites/phpstorm/start/app/bootstrap.php.cache): failed to open stream: No such file or directory in /Users/dougouverson/Sites/phpstorm/start/app/console on line 10

    Fatal error: require_once(): Failed opening required '/Users/dougouverson/Sites/phpstorm/start/app/bootstrap.php.cache' (include_path='.:') in /Users/dougouverson/Sites/phpstorm/start/app/console on line 10"

    Could you please recommend a video or resource to help me with getting symfony running on my Mac.

    FYI: I'm a Drupal site-builder, learning PHP programming within Drupal 8 content. I'm not a complete newbie (I have 8+ years experience as sysadmin), but I am new to symfony.

    Thank you, and kind regards,

  • 2015-11-08 weaverryan

    Hi there!

    To actually get the application running, go into your terminal and run this command (from inside the project's directory):


    php app/console server:run

    You can see more about this here: http://knpuniversity.com/scree...

    I don't think I mentioned this in the screencast - this is more a "how do I get my Symfony app" running - it's not related to PhpStorm. But, I probably should have mentioned it :).

    Cheers!

  • 2015-11-08 WEB BY DOUG

    Following along with no issues, until the very end: http://localhost:8000 did not produce symfony page, and no symfony menu in bottom right-hand. I do have the plugin installed; and I did restart PhpStorm. I'm running 10.0