, (*1)
Genesis is lightweight, smart and easy to use CLI tool, for building (mainly) PHP applications.
Usage is similar to Phing, but Genesis is much easier.
For configuration is used an .neon file, which is very similar to YAML., (*2)
Installation
Preferred installation is with Composer., (*3)
composer require genesis-php/genesis
, (*4)
Compatibility
This software is developed primarily for UNIX systems (Linux, OSX),
but it works also on Windows., (*5)
Quick example
Look at the example which gives you quick introduction.
Don't worry, it will take only minute., (*6)
Getting started
Initialize build directory in your project:
(path to your vendor directory may differ!)
../vendor/bin/genesis self-init
, (*7)
An 'build' directory will be created, with these files:
- Build.php
- PHP class with runXyz() methods
- every public method starting with 'run' is an "Task"
- in task you can run any code you want
- there is public method 'setup', it runs slightly after Build class is constructed
- for example
- config.neon
- config in NEON format (very similar to YAML)
- define parameters and services
- you can include another configs directly in NEON file:
includes:
- include.neon
- if you don't want to merge any config variable, add ! (exclamation mark), eg:
myParam!: unoverrided value
- for example
- bootstrap.php (optional)
- to load Build class and other classes
- for example
- build (optional)
- shell script which is only shortcut into vendor directory with genesis, (*8)
Look at the skeleton, how can build directory looks like., (*9)
CLI
This tool is intended to use via CLI only., (*10)
Run it by (path to your vendor directory may differ!):
../vendor/bin/genesis mytask
, (*11)
OR via shortcut, which creates self-init (you may need to edit path to vendor dir in file 'build/build'):
./build/build mytask
, (*12)
You can use any working directory with parameter "--working-dir":, (*13)
Supported options:
- --working-dir /var/www/myproject
- use specified working directory
- --colors 0
- disable colored output
- --config myconfig.neon
- use specified config, (*14)
All arguments are passed to build:, (*15)
../vendor/bin/genesis mytask foo
, (*16)
Arguments mytask and foo will be available in your build class (property $arguments), (*17)
Commands
Commands are intended to use them in Tasks.
In namespace Genesis\Commands are default commands and of course you can create and use your own commands., (*18)
Common
-
Exec
- executes shell command
- returns an ExecResult including return code and output
-
Git
- executes Git command & can clone any repository
- returns an ExecResult including return code and output
-
Help
- prints list of available tasks to output
- list is given in simple array
-
NodeJs
- can install packages (npm install) in any directory
-
PhpUnit
- can run PHPUnit tests in any directory & provides some setup
-
NetteTester
- can run Nette Tester tests in any directory & provides some setup
Assets
-
Assets\Gulp
- Running gulp, usually to build frontend
- You can setup gulpfile location
-
Assets\Less
- if you want only compile LESS files on build, you can use this command
- using NodeJs lessc tool
Filesystem
Test
This set of commands may be useful, if you want to check system some system requirements,
usually at the beginning of the build.
- Test\NodeJs
- tests NodeJs version
- Test\Php
- tests PHP ini settings
- tests if desired extension present
- Test\NodeJs
- tests if desired programs is installed (on UNIX), (*19)
Integration
An bootstrap.php in build directory can return instance of Genesis\Config\Container
which will be merged into Container created from config.neon, (*20)