Componette

Componette

Joseki

Joseki / FileTemplate v0.2.5

PhpStorm FileTemplate generator for Nette Framework application using Symfony/Console

download-cloud-line composer require joseki/file-template

Joseki/FileTemplate

Build Status Latest Stable Version

Requirements

Joseki/FileTemplate requires PHP 5.4 or higher.

Installation

The best way to install Joseki/FileTemplate is using Composer:

$ composer require joseki/file-template

Register compiler extension in your config.neon:

extensions:
  FileTemplate: Joseki\FileTemplate\DI\FileTemplateExtension

Example

Add the following to your config.neon:

extensions:
  FileTemplate: Joseki\FileTemplate\DI\FileTemplateExtension

FileTemplate:
  # root dir for new files
  rootDir: '%appDir%' # [OPTIONAL], %appDir% is default

  # list of file templates groups
  commands:
    example1: # group name used in command line
      variables: ['CONTROL', 'NAMESPACE']
      templates:
        CONTROL_FILE: '%appDir%/templates/control.txt'
        FACTORY_FILE: '%appDir%/templates/factory.txt'
        TEMPLATE_FILE: '%appDir%/templates/template.txt'
      defaults: # [OPTIONAL] default values for variables
        CONTROL_FILE: '${CONTROL}.php'
        FACTORY_FILE: '${CONTROL}Factory.php'
        TEMPLATE_FILE: template.latte

Running a console command

app/console joseki:file-template COMMAND [--dir=RELATIVE_DIRECTORY]

for example:

app/console joseki:file-template example1

Suppose that variables ${CONTROL} = Hello and ${NAMESPACE} = Foo, then the previous command will create these files:

  • %appDir%/Foo/Hello.php
  • %appDir%/Foo/HelloFactory.php
  • %appDir%/Foo/template.latte

and when a directory is specified:

app/console joseki:file-template example1 --dir=MyApplication/Auth

...these files will be created:

  • %appDir%/MyApplication/Auth/Hello.php
  • %appDir%/MyApplication/Auth/HelloFactory.php
  • %appDir%/MyApplication/Auth/template.latte

NOTE: you will be prompted to define your file template variables

NOTE: this extension should be compatible with Joseki/Console and Kdyby/Console.

  • v0.2.5 Released version 0.2.5

    • ControlCommand: fixed variable resolving before using any variable directly
  • v0.2.4 Released version 0.2.4

  • v0.2.3 Released version 0.2.3

    hotfix for unstable Symfony v2.8

  • v0.2.2 Released version 0.2.2

    Output filepath normalized:
    C:\path\to\new/file will be now displayed as C:/path/to/new/file

  • v0.2.1 Released version 0.2.1

    • DI: fixed variable defaults
  • v0.2.0 Released version 0.2.0

    • changed variable syntax to ${VAR}
    • renamed command name to joseki:file-template
    • added default variables ${DS} and ${NAMESPACE} to correspond more with PhpStorm behaviour
    • improved variable resolution
    • fixed destination directory creation
    • argument DIR replaced with optional option --dir=path
  • v0.1.2 Released version 0.1.2

    Refactorization

  • v0.1.1 Released version 0.1.1

    Fixed namespaces

  • v0.1 Released version 0.1

    Released brand new tool for PhpStorm and Nette applications.

    Define your multi-file templates with minimum effort. Just fill your config file and for each new file (group of files) simply run Symfony/Console (or better Joseki/Console or Kdyby/Console tools).

    Profit.

Componette Componette felix@nette.org