blog.Resource

Archive:

News-Feeds:


RSS 2.0
RSS 0.91
RDF
ATOM 0.3
April 30, 2013

Howto: Autocompletion for fluid in PhpStorm

Category: Extbase

By: Anja Leichsenring

Schema Setting in Phpstorm

 

As a TYPO3 extension developer, you might already use PhpStorm as your IDE, it gives you so many benefits in your PHP coding. You probably love the auto completion, syntax highlighting and keyboard shortcuts. One missing bit is that Storm by default does not understand the Fluid template engine syntax and paints lots of red marks to your code. But thankfully, the designers of Fluid made the template engine compatible to XML standards, so it is possible to enable PhpStorm understand the bits and pieces of this.

This howto is about getting PhpStorm understand and autocomplete your fluid code.

Thanks to the a schemagenerator by Claus Due (@NamelessCoder), there is an easy way. On his website http://www.fedext.net you can download the xsd schema files for the TYPO3 system extension fluid, as well as for his own collection of extensions. As a bonus you can create the schema for your own viewhelpers.

Steps:

  • Download the fluid xsd and store it locally.
  • Open the "Settings" dialog of PhpStorm. This is a project based setting, keep in mind to repeat this step for other projects.
  • Insert a new record into the Schema and DTD -> external schema section (refer to the attached image how this looks like).
  • Choose an uri according to your liking, it must be unique, and relate it with the xsd file. 
  • Save the changes and close the settings dialog.
  • Use "xmlns" tag in your layouts, templates and partials. Thats possible by using sections.

Example for a Template file (using a Layout that only contains the main section):

<div xmlns="http://www.w3.org/1999/xhtml" lang="en"
     xmlns:f="http://typo3.org/ns/fluid/ViewHelpers" >
<f:layout name="Default" />
<f:section name="main" >
 // your fluid code is here
</f:section>

Example for a Partial file:

<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
      xmlns:f="http://typo3.org/ns/fluid/ViewHelpers">
<head>
 <title>Partials: ValidationResults</title>
</head>
<body>
<f:section name="Main">
  // your fluid code is here
</f:section>
</body>

Enjoy increased coding speed and decreased typos in your TYPO3 Fluid Views ;)


comments

comment #1
Gravatar: Karsten Dambekalns Karsten Dambekalns May 4, 2013 22:10
If no project is open in PhpStorm, it is possible to set "Template Project Settings" that are used for any new project. Very useful to avoid repeating of setting this and other options.

Another way to ease making this setting for multiple projects is to export it once and import it into further projects - that saves a few clicks.

Sorry, comments are closed for this post.