Image

Spawner

Spawn boilerplate code for any PHP application component

Development Boilerplate Generator PHP

Actions

Action defines the processes that this command will do based on user inputs. They are defined by specifying an array of actions. Depending on the type of action to be performed, their keys differ.

actions:
  - action: copy
    if: template
    source: Form/template/template.html
    target: ${path}/${id}.template.html.twig

The if directive is available to all actions. It allows a specific action only if a certain user input variable evaluates to true.

Default Actions

Spawner ships with some default actions which you can immediately use.

Copy

Copies a file to a specified location

- action: copy
  source: Form/template/template.html
  target: ${path}/${id}.template.html.twig
  • Source (Required) - The source file you wish to copy
  • Target (Required) - The destination path including the file name

Template

Copies an evaluated Twig template file to a specified location

- action: template
  source: Form/template/Form.php.twig
  target: ${path}/${name}.php
  replacements:
    form_name: ${name}
  • Source (Required) - The source file you wish to copy
  • Target (Required) - The destination path including the file name
  • Replacements (Optional) - Accepts a key value pair of data to be passed to Twig template

Append

Appends a string to a contents of a file using pattern matching

- action: append
  target: components.ts
  text: ${name}
  pattern: /^/
  • Target (Required) - The file to be modified
  • Text (Required) - The text to be appended to the file
  • Pattern (Optional) - If specified will append the text to the location of the pattern

YAML

Create or appends data to a YAML file

- action: yaml
  target: config/list.yml
  append:
    items:
      name: ${name}
  • Target (Required) - The file to be modified, will create the file if empty
  • Append (Required) - An associative array that will be merged against the existing YAML
  • Spaces (Optional) - Specify the number of spaces the resulting YAML file will contain

Notify

Displays a message to the user

- action: notify
  message: Form generated successfully
  type: success
  • Message (Required) - The notification message
  • Type (Required) - The type of message to display, values can be success, info or error