Setting up PhpStorm for use as a FLOW3 IDE

The world has seen it's share of PHP IDEs during the past years. All the time we had to envy the Java folks for their really well-working IDEs and the support they provided while coding.

Then came along JetBrains and produced something called PhpStorm. I frowned upon the mixed-case use of Php but gave it a try. I liked it. Then the JetBrains people gave a free license to the core developer team of the TYPO3 project. That's when other also started to adopt it. By now I have the feeling that most people around me use it.

As with all powerful tools some customization is needed to make it work the way you need. So here goes a list of things you should customize to get the best out of PhpStorm when developing on and with FLOW3. This post deals with overall settings - another post on setting up a custom project to deal with FLOW3 specifics will follow.

If you want to read this post but do not want to do all the clicks yourself, you can import (selectively) from my exported settings file. Just use the Import Settings… menu item in PhpStorm.


First some settings that are not really related to FLOW3.

IDE Settings

If you are on a Mac, the first thing should be the selection of the Mac OS X 10.5+ keymap in IDE Settings > Keymap. Otherwise you'll probably be very puzzled about a number of shortcuts.

Then you might want to fill in your GitHub credentials in the IDE Settings > GitHub.

The next thing I recommend is to switch off Save files on frame deactivation in IDE Settings > General. I often change some code and then go to check something on the web or do something in my shell window. If you then have a half-done change saved to disk, that can be very puzzling.

Next up is the IDE Settings > Editor section. Here are some things that I consider basic as well. Strip trailing spaces on Save should always be set to All. Allow placement of caret after end of line on the other hand never came in handy for me. But very useful are Highlight current scope and Highlight usages of element at caret.

We continue in the IDE Settings > Editor > Smart Keys section. The Use "CamelHumps" words makes the movement in camelcased words easier. What you choose for Reformat on paste is up to you, play around with it to find your personal favorite.

In the IDE Settings > Editor > Appearance section you should switch on Show line numbersShow method separators and Show whitespaces. It will make you a better and faster coder. :)

IDE Settings > Editor > Editor Tabs has the very useful Show directory in editor tabs for non-unique filenames setting. I love that. As well as Mark modified tabs with asterisk.

I like to see all the code I work on, so in the IDE Settings > Editor > Code Folding section I leave folding enabled but disable all default folding.

Why IDE Settings > Diagrams has all the PHP Class Diagrams disabled by default is greek to me.

Template Project Settings

Hint: make sure no project is open before you call up the PhpStorm preferences, so you actually have access to the Template Project Settings.

In Template Project Settings > PHP you should now set up your PHP Interpreter. This involves adding one or more interpreters first by clicking the small button with the dots.

Then for good measure check that Template Project Settings > File Encodings has the IDE Encoding set to UTF-8.

Next you should go to Template Project Settings > Inspections and disable the processing of code for the Spelling > Typo inspection. I mean, really…

Then switch on the PHP > PHPDoc > Missing PHPDoc comment inspection in Template Project Settings > Inspections.


Now we are down to the FLOW3 specific settings.

Code Style

It makes sense to create dedicated profiles for each coding guideline you might need to follow. So first use the Save As… button in Template Project Settings > Code Style to save a FLOW3 code style scheme. Then adjust as follows:

In Template Project Settings > Code Style > General set the Line separator to Unix and check the Use tab character option for indentation.

In Template Project Settings > Code Style > PHP > Tabs and Indents check the Use tab character option for indentation. The other options can be left at their default.

In Template Project Settings > Code Style > PHP > Spaces all options can be left at their default.

In Template Project Settings > Code Style > PHP > Wrapping and braces make sure Braces placement is set to "End of line" for the three available settings. Wherever possible select "Always" for Force braces and "Do not wrap" everywhere you can. Then uncheck all the Align when multiline options.

In Template Project Template Project Settings > Code Style > PHP > Blank Lines set the Keep Maximum Blank Lines to 1/1/0 and the Minimum Blank Lines to 1/1/1/1/0.

In Template Project Settings > Code Style > PHP > PHP Doc uncheck Keep blank lines and check Blank line before the first tag.

In the other sections below Template Project Settings > Code Style check the Use tab character option for indentation.

Other settings

One more thing: If you intend to edit XLIFF files with PhpStorm, download the strict XLIFF schema and save it somewhere convenient. Then in the Template Project Settings > Schemas and DTDs add an entry for External  Schemas and DTDs by clicking the plus icon. Enter urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd as URI and select your saved schema file

What you do to the colors and fonts is up to you. If you feel you need to change things there, check out Solarized first. Someone gave the whole topic a bit of thought already.


That's it for now. Enjoy and never again push something to review.typo3.org that violates the CGL! ;)


Unknown said...

He, are you happy with the "code completion" from PhpStorm in FLOW3 Projects?

Karsten said...

Yes, code completion works really well. Any specific issues you are having?

The proxy class building causes some "duplicate" classes, that confuses PhpStorm slightly - maybe that causes some issues for you?

I'll address that in my next post, though.

Anonymous said...

Merci fürs Tut.!

Andreas said...

You wrote: Minimum Blank Lines to 1/1/1/0

But I have 5 options (phpstorm 3.0):
- Around class
- After class header
- Around field
- Around method
- Before method body

Karsten Dambekalns said...

Andreas, you are right. Probably missed one, it should be 1/1/1/1/0. I fixed it in the text as well.

Bastian said...

Very nice, thanks for the collection!
I agree to all except for disabling the spell checker - it made me stumble upon a lot of typos in FLOW3 code & comments already!

Karsten Dambekalns said...

Bastian, I also have the spellchecker enabled, just not for actual code. Indeed, having it check comments and whatever else saved me from a bunch of typos as well…

Tad Fuller said...

PhpStorm is designed on Java.Java is a prehistoric language and the VM which needs to whirl up to perform Java applications is one of the biggest storage and CPU hogs – especially when operating in an OSX atmosphere.

Karsten Dambekalns said...

@Tad: I don't agree to Java being bad per se - but even if it was, what is your suggested alternative to PhpStorm in particular?

Anonymous said...

Thanks Karsten, I just started using phpstorm and your downloadable .jar file really saved me a lot of time. Thanks for going the extra mile for the rest of us.

Jagna Co Kalani said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training from India . Nowadays Java has tons of job opportunities on various vertical industry.