blog.Resource

Archive:

News-Feeds:


RSS 2.0
RSS 0.91
RDF
ATOM 0.3
September 25, 2014

Something Neos VII - Riders on the PHPStorm

Category: Florian Weiss

By: Florian Weiss

Getting more out of your IDE for Neos Development

Reap the rewards of XML conformity

If you use PHPStorm or another similar powerful IDE for development you might already have wondered: "With all the great autocompletion and markup for various languages - can I get that for NEOS development too?" - of course you can.

You are using Fluid - and Fluid has perfect XML conformity.
If you are looking at the curly brackets in your templates now and wonder wether XML has been extended or if I've gone insane (might be you are leaning towards the latter), please check out http://fluidtypo3.org/documentation/templating-manual/appendix/fluid-autocompletion.html.

From there we can learn that we don't have to use the Fluid-style namespace - but can also use the XML namespace syntax.

That's a big deal - because suddenly PHPStorm can recognize our schemas if we map them as local resources.
But wait - we don't have any schemas for our ViewHelpers ready - do we?

Creating schemas with FLOW

Well at the moment we don't have any schemas at hand to let PHPStorm look up our ViewHelper tags - but there's a built in way in flow to create them on the fly.

Either just run

./flow help

to see all available commands, or check out the Command Line Reference on the web.

The command used to create the schemas is

./flow documentation:generatexsd

Example: Creating a schema file for FLUID

The files are inside ./Packages/Framework/TYPO3.Fluid/Classes/TYPO3/Fluid/ViewHelpers and when we check out one of the files in there we can learn that the namespace is "TYPO3\Fluid\ViewHelpers" (right at the top)

At generation we also have to consider that the XSD filename has to match the second last part of the xmlns definition case sensitively.
For our example the command we need to run in our shell is:

./flow documentation:generatexsd TYPO3\\Fluid\\ViewHelpers > Fluid.xsd

This will write the output into the current directory - which is not a problem because we don't need the schema file on the server anyways. This is just for your IDE (e.g.: PHPStorm)
So move the file you just created to your dev machine and open it with any fitting editor to check out the "targetNamespace".

Remember that the targetNamespace inside the xsd files included in your IDE (which we will perform in the next step) must match the uris defined in the xmlns you use in your templates. (in our example: typo3.org/ns/TYPO3/Fluid/ViewHelpers)

Referencing to the schemas in PHPStorm

All that's left to do is referencing to the schemas in PHPStorm.
This can be done via

File - Settings - Schemas and DTDs

Click the little + icon, enter the targetNamespace you checked out before in the file (in our example: typo3.org/ns/TYPO3/Fluid/ViewHelpers) and choose the according file from the browser.

In the screenshot you can see my settings (I already included a bunch of other schemas I use regularely)

After setting everything up, you can use the xml-style namespace in your templates to activate autocompletion and suggestions. (e.g.: <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers">)
In case you have the same ViewHelpers included with fluid-style syntax, you can remove that one.

Enjoy:

In case you don't want to go through all the file creation processes yourself, you can find a schema package at: http://www.weissheiten.at/NEOSSchemas.zip .

Update 26.09.2014: In case you don't want to set this for each project seperately, open the configuration from the splash welcome screen in the "template project settings"

But wait - T(here i)S more!

The nice guys and girls of Sgalinski got us TypoScript support too - yes, that is also true for TS2.
Intellisense is not here yet - but you can get great features like highlighting and bracket info by getting the plugin at: http://www.sgalinski.de/open-source/typoscript-plugin.html


Think we are ready for some more NEOS now? Join me again next time, when we look at the 2nd part for page templating.


comments

comment #1
Gravatar: Simon Simon October 2, 2014 14:25
How can I avoid the errors in the if condition?



gives me an error in PhpStorm: Wrong attribute value.

comment #2
Gravatar: Simon Simon October 2, 2014 14:27
oh, ve_guestbook sucks. here my tag again:

[f:if condition="{...}"]

comment #3
Gravatar: Florian Weiss Florian Weiss October 6, 2014 09:55
I think you are talking about TYPO3 CMS now? Regarding NEOS you'd use a condition to the best of my knowledge (http://docs.typo3.org/neos/TYPO3NeosDocumentation/Appendixes/NeosTypoScriptReference.html) or in fluid you'd need a html style bracket < not [

Sorry, comments are closed for this post.