dev-master
9999999-devPackage to make deploy PHP applications. It's similar to capistrano (Ruby).
MIT
The Requires
- php >=5.3.0
- elfet/deployer v0.4.2
php deploy capistrano deployer tokenpost
Package to make deploy PHP applications. It's similar to capistrano (Ruby).
Library to make deploy apps written in PHP. It's based on Capistrano in Ruby., (*1)
The recommended way to get a working copy of this project is to clone the repository
and use composer
to install dependencies adding these lines in composer.json:, (*2)
{ "require": { "tokenpost/caphpistrano": "dev-master" ... } }
The CaPHPistrano is very similar to Capistrano in ruby. We need to run this command to create our files to deploy., (*3)
vendor/bin/caphp install
This command will be create these files:, (*4)
./deploy.php ./config/deploy ├─ default.ini └─ environments ├─ development.ini └─ production.ini
In these ini files, exists the configurations to ssh, git and composer in remote server.
In the default.ini
file, you must insert the information that will be common in all files and in environments files you must be insert the informations for each environment., (*5)
This is the default.ini
file., (*6)
;Application []: application = name of your application [git] repository = https://user:pass@github.com/user/application.git ; Repository with name and pass in format https. branch = master ; Name of branch [ssh] ; The deploy only works with ssh deploy_to = /var/www/website.com ; remote folder user = root ; username remote use_sudo = false ; If you need to call sudo command password = mypassword ; password remote (optional) port = 22 ; port (default=22) server = website.com ; server name keep_releases = 5 ; Quantity of releases that you want to keep in remote server [composer] use = true ; If you want to use composer (default = true) command = /var/www/composer.phar ; If you put the composer.phar in user/local/bin/composer.phar you can run only composer.phar, some else, /path/of/composer.phar installOnDeploy = true ; If the script cannot find the composer, you want to try to install automatically ? [shared] ; Shared folders and files. Is different off capistranorb. Here, if the file isn't exists, the caphpistrano copy the files in the shared folder files[] = config/autoload/doctrine_orm.local.php ; array with files files[] = config/autoload/zendconfig.local.php ; array with files dir[] = data/uploads ; array with folders dir[] = data/cache ; array with folders [writable] ; folders and files with 777 permissions dir[] = public/cache ; dir array dir[] = data/cache ; dir array dir[] = data/cache/thumbs ; dir array
After this you can run these commands:, (*7)
$ vendor/bin/caphp install $ vendor/bin/caphp create:environment $ vendor/bin/caphp list environments $ vendor/bin/caphp list tasks $ vendor/bin/caphp deploy:setup $ vendor/bin/caphp deploy:check $ vendor/bin/caphp deploy $ vendor/bin/caphp deploy:cold $ vendor/bin/caphp deploy:rollback
Now, you can make a simple deploy in your application. First you need to run this command:, (*8)
$ vendor/bin/caphp deploy:setup
This command will generate two folders releases
and shared
.
Now you can run this command:, (*9)
$ vendor/bin/caphp deploy
This command will be create a new folder with your application in releases, and will create a symlink called current
., (*10)
After you change the values in the ini file, you can start to write your own tasks.
Create a new file (example: deploy.php)
and insert this code., (*11)
$caphp = new TokenPost\CaPHPistrano; # Command to create a new task. $caphp->task('commandTask','Description of this task', function() use (&$caphp) { $caphp->writeln('<comment>Hello</comment>, i\'m a task...'); }); $caphp->start();
And run in terminal:, (*12)
$ vendor/bin/caphp deploy.php commandTask Hello, i'm a task...
If you want to make a sequence of tasks, you can pass in third param an array with the names of the tasks. Ex:, (*13)
$caphp->task('sequence','Sequence of tasks',['task1','task2','task3']);
If you want to add a task after another task, you can add this line., (*14)
$caphp->task('myTaskAfterDeploy','This is my task after deploy.',function() { $this->writeln('This will be run after another task.'); }); // The second param, must be an array with the name of tasks. $caphp->after('deploy',['myTaskAfterDeploy']);
If you want to add a task before, you can use the method before., (*15)
// The second param, must be an array with the name of tasks. $caphp->after('deploy',['myTaskBeforeDeploy','anotherTask']);
If you run the deploy
the sequence will be myTaskBeforeDeploy
, anotherTask
, deploy
, myTaskAfterDeploy
when ran $ vendor/bin/caphp deploy
., (*16)
If you find any bugs, please send an email to renatocassino@gmail.com., (*17)
Package to make deploy PHP applications. It's similar to capistrano (Ruby).
MIT
php deploy capistrano deployer tokenpost