3.1.1 Generating a Provider extension

FluidTYPO3 File contexts, full

This chapter of the documentation describes how to build code automatically. There are a few features in the Fluid Powered TYPO3 family which enable automatic code generation based on conventions. The first and most important such feature is the code generation features of EXT:builder which can be found on Github: https://github.com/FluidTYPO3/builder.

EXT:builder provides a few methods to validate and build code.

Generating a Provider Extension

The easiest way to use EXT:builder to create your Provider Extension is to use the included backend module. Simply install EXT:builder, reload the TYPO3 backend and select the new "Builder" menu item. Fill in the author etc. values and press "create", then install your extension.

Command Line option

For those wanting to automate this or preferring to use CLI, there is also a CLI version of the Provider Extension generator. By running this CLI Command made available by EXT:builder, you can create a skeleton extension with a basic set of files and configuration by using just a single command (from your TYPO3 document root):

./typo3/cli_dispatch.phpsh extbase builder:providerextension <arguments>

The command supports a wide range of arguments to affect which features the extension should use and how it should be built.

  --extension-key      The extension key which should be generated. Must not
                       exist in the typo3conf/ext folder.
  --author             The author of the extension, in the format "Name
                       Lastname <[email protected]>" with optional company name,
                       in which case form is "Name Lastname <[email protected]>,
                       Company Name"

  --title              The title of the resulting extension, by default
                       "Provider extension for $enabledFeaturesList"
  --description        The description of the resulting extension, by default
                       "Provider extension for $enabledFeaturesList"
  --use-vhs            If TRUE, adds the VHS extension as dependency -
                       recommended, on by default
  --pages              If TRUE, generates basic files for implementing Fluid
                       Page templates
  --content            IF TRUE, generates basic files for implementing Fluid
                       Content templates
  --backend            If TRUE, generates basic files for implementing Fluid
                       Backend modules
  --controllers        If TRUE, generates controllers for each enabled feature.
                       Enabling $backend will always generate a controller
                       regardless of this toggle.
  --minimum-version    The minimum required core version for this extension,
                       defaults to latest LTS (currently 4.5)
  --dry                If TRUE, performs a dry run: does not write any files
                       but reports which files would have been written
  --verbose            If FALSE, suppresses a lot of the otherwise output
                       messages (to STDOUT)

Depending on which toggles you use, template files will be built for EXT:fluidcontent, EXT:fluidpages and/or EXT:fluidbackend, all containing a basic set of configuration enabling the file to be used by each extension. To make a "dry run" specify --dry 1 which means no files/folders are written but the intent to create each file/folder is output instead. You can even initialise and initially commit all files as a git repository (requires the git CLI command to be available to the current shell user).

For example, such a build command might look like:

./typo3/cli_dispatch.phpsh extbase builder:providerextension \
    --extension-key test --author "Claus Due <claus@***********.net>" \
    --pages 1 --content 1 --controllers 1 --git 1 --travis 1 --use-vhs 1

Which would generate the extension key test authored by Claus Due with email claus@***********.net and include page and content templates as well as controller classes for each, a Travis-CI build script to go along with the extension and finally will create a git repository in the extension folder and initially commit all files.

You can then very easily install the generated extension also from the command line:

./typo3/cli_dispatch.phpsh extbase builder:install test

Which simply installs the extension key "test" (note: this feature only works on 6.0+ TYPO3 sites). All you then need to do is load the static TypoScript into each root template where you want the content/page templates to be available - and start adding your own templates or adjusting the pre-built placeholder templates.

Jump to...