5.3 Fluid template auto completion

How to use xmlns in PhpStorm and Fluid

{namespace v=FluidTYPO3\Vhs\ViewHelpers}
<div xmlns="http://www.w3.org/1999/xhtml" lang="en"

    <!-- Fluid goes here -->

If you use the XML namespace syntax above, the default pattern http://typo3.org/ns/<php namespace> is resolved automatically by the Fluid template parser (see TYPO3 Flow Documentation). Thus if you use xmlns:flux="http://typo3.org/ns/FluidTYPO3/Flux/ViewHelpers" you don't have to set the old Fluid-style namespace {namespace flux=FluidTYPO3\Flux\ViewHelpers} in your fluid templates. When used this way, your ViewHelpers' namespaces can also help your code editor identify which so-called schema file (XSD) contains declarations of possible tag names, required attributes, argument descriptions and so on.

The extension schemaker allows you to create XSD files which XSD-capable code editors can use to enable auto completion of the Fluid template tags. To get Fluid autocompletion using XSD files (see 1 and 2) working in PhpStorm assure that:

  • The targetNamespace inside the included xsd files (and when generating the XSD) match the uris defined in xmlns.
  • The XSD filename case sensitively matches the second last part of the xmlns definition (e.g YourPlugin.xsd for xmlns:yp="http://typo3.org/ns/Vendor/YourPlugin/ViewHelpers").

Non namespaced ViewHelpers are genereated using the simple extension key:

./typo3/cli_dispatch.phpsh extbase schema:generate vhs > vhs.xsd
./typo3/cli_dispatch.phpsh extbase schema:generate fluid > fluid.xsd

Namespaced ViewHelpers must to use <vendor>.<extension name> syntax for parameter --extension-key of schema:generate:

./typo3/cli_dispatch.phpsh extbase schema:generate FluidTYPO3.Flux > Flux.xsd
./typo3/cli_dispatch.phpsh extbase schema:generate Vendor.YourPlugin > YourPlugin.xsd

The output files will be in the site's document root after running these commands - you can move them to any place you like. TYPO3 itself does not require these files; you only need them locally for your code editor to use them.

Jump to...