Spawn boilerplate code for any PHP application component

Development Boilerplate Generator PHP

Install via Composer

$ composer require alexecus/spawner

Creating the Application Instance

Create a file that will act as your main executable, let's say the filename is console and you put it in a bin folder on your application


#!/usr/bin/env php

require __DIR__ . '/../vendor/autoload.php';

$app = new Alexecus\Spawner\Application();

$app->addDefinition(__DIR__ . '/Form/definition.yml', __DIR__);


Make sure the file is executable by running

$ chmod a+x bin/console

Adding Definitions

Add definitions by calling the add definition method. It accepts 2 arguments

  • The location of the YAML file
  • The base path the definitions inside the YAML file will look into
$app->addDefinition(__DIR__ . '/Form/definition.yml', __DIR__);

It is recommended to have one definition file per command

Definition File

The definition is simply a YAML files, it has 3 parts

  • Command description - Describes your command details and how to execute it
  • Inputs - Defines the user input your command will accept
  • Actions - Defines the actions your command will do base on user inputs
name: My Command
command: command:alias
description: Description of my command



You definition file will be executed by running the following and specifying your command alias

$ ./bin/console command:alias