staempfli / universal-code-generator
Staempfli AG - Universal Code Generator Tool
Installs: 3 527
Dependents: 1
Suggesters: 0
Security: 0
Stars: 5
Watchers: 4
Forks: 3
Open Issues: 0
Type:staempfli-tool
Requires
- symfony/console: ~4.0|~3.0|~2.7
- symfony/yaml: ~4.0|~3.0|~2.1
README
This tool can be used as base for creating code generators for specific frameworks
Usage
-
Create your own generator project:
- Check an example here: magento2-code-generator
-
Add this project as dependency
composer require "staempfli/universal-code-generator":"~1.0" composer update
-
Copy needed default configuration file
$ cp vendor/staempfli/universal-code-generator/config/default-properties.yml.dist config/default-properties.yml
-
You need to create a PHP script to define the console application:
-
We recommend to do that into the
bin
foldercd bin && vim <command_name>
-
Add the following content to this file:
#!/usr/bin/env php <?php $composerAutoload = __DIR__ . '/../../../autoload.php'; if (file_exists($composerAutoload)) { require_once $composerAutoload; } else { require_once __DIR__ . ' /../vendor/autoload.php'; } /** * Shortcut constant for the project root directory */ define('BP', dirname(__DIR__)); /** * Command name */ define('COMMAND_NAME', basename(__FILE__)); // Init Console Application use Staempfli\UniversalGenerator\Application; $application = new Application('@git-version@'); /** * You can add new commands or extend exiting ones to add custom functionality * - Check default commands in Staempfli\UniversalGenerator\Application * - To add or extend commands you must use the method $application->addGeneratorCommand */ // $application->addGeneratorCommand('template:generate', 'VendorName\ProjectName\Command\TemplateGenerateCommand'); $application->run();
-
-
Usually you might want to extend the default
template:generate
command. You can do that as follows: -
Create the templates that will be generated:
Prerequisites
- PHP >= 5.6.*
Developers
Licence
GNU General Public License, version 3 (GPLv3)
Copyright
(c) 2016 Staempfli AG