A Helper, or more precisely a ViewHelper, is a class that helps organize pure code from the context of pure template files by handling common and repetitive tasks. A use case for this could be a class that wraps the logic of thumbnail presentation for instance.

Creating a Helper file.

To generate a ViewHelper, you should use the automated generator provided by Strata. It will validate your object’s name and ensure it is defined following the intended conventions.

Using the command line, run the generate command from your project’s base directory. In this example, we will generate a view helper for the Artist object:

$ ./strata generate helper Artist

The command generates a couple of files for you, including the actual ViewHelper file and test suites for the generated class.

Scaffolding controller ArtistController
  ├── [ OK ] src/View/Helper/ArtistHelper.php
  └── [ OK ] test/View/Helper/ArtistHelperTest.php