Download the PHP package yidas/deployer-php-cli without Composer
On this page you can find all versions of the php package yidas/deployer-php-cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yidas/deployer-php-cli
More information about yidas/deployer-php-cli
Files in yidas/deployer-php-cli
Package deployer-php-cli
Short Description Code deployment tool based on RSYNC running by PHP-CLI script
License MIT
Homepage https://github.com/yidas/deployer-php-cli
Informations about the package deployer-php-cli
Deployer PHP-CLI
CI/CD Deployment tool written in PHP supported for popular frameworks
FEATURES
-
Deploy to multiple servers by projects/groups
-
Yii2, Laravel, Codeigniter3 Frameworks support
-
Pipeline support for Git, Composer, test and customized tasks
- CI/CD automation solution
Helping developers to deploy codes from local instance to remote instances.
OUTLINE
- Demonstration
- Requirements
- Installation
- Composer Installation
- Wget Installation
- Make Command
- Startup
- Upgrade
- Configuration
- Project Setting
- Config Options
- Git
- Composer
- Test
- Tests
- Rsync
- Commands
- Example
- Usage
- Interactive Project Select
- Non-Interactive Project Select
- Skip Flows
- Revert & Reset back
- Implementation
- Permissions Handling
- CI/CD
- Webhook
- PHP Web Setting
- Gitlab
- Additions
- Rsync without Password
- Save Binary Encode File
- Yii2 Deployment
- Minify/Uglify by Gulp
DEMONSTRATION
Command Line
Deploy local project to remote servers by just executing the deployer in command after installation:
Alternatively, you could call the original bootstrap:
$ ./deployer
,$ php ./deployer
The interactive result could like be:
Or you could run by non-interactive mode with the same purpose:
REQUIREMENTS
This library requires the following:
- PHP(CLI) 5.4.0+
- RSYNC
INSTALLATION
Composer Installation
Using Composer by sudoer
or root
to install is the easiest way with auto-installer:
Wget Installation
You could see Release for picking up the package with version, for example:
After download, uncompress the package:
In addition, you can rename the unzipped folder by
mkdir deployer-php-cli && tar -zxvf deployer-php-cli.tar.gz --strip-components 1 -C deployer-php-cli
Make Command
To make a command for deployer, if the package folder is deployer-php-cli
then create a symbol by following command:
Startup
After installation, you could start to set up the config.inc.php
for deployer, and enjoy to use:
Upgrade
To upgrade, you could re-install the deployer and copy the old config.inc.php
to the new one, for example:
CONFIGURATION
Project Setting:
You need to set up the projects configuration such as servers, source and destination in config.inc.php
file:
You could refer config.inc.php file as an example..
Config Options:
Configuration provides many features' setting, you could customize and pick up the setting you need.
Key | Type | Description |
---|---|---|
servers | array | Distant server host list |
user | array|string | Local/Remote server user, auto detect current user if empty |
source | string | Local directory for deploy, use / as end means * |
destination | string | Remote path for synchronism |
exclude | array | Excluded files based on sourceFile path |
verbose | bool | Enable verbose with more infomation or not |
Git
To use Git into deploy task, you need to init or clone Git to the source directory at the first time:
Key | Type | Description |
---|---|---|
enabled | bool | Enable git or not |
checkout | bool | Execute git checkout -- . before git pull |
branch | string | Branch name for git pull, pull default branch if empty |
submodule | bool | Git submodule enabled |
Composer
To use Composer into deploy task, make sure that there are composer files in the source directory.
Key | Type | Description |
---|---|---|
enabled | bool | Enable Composer or not |
path | string | Composer executing relative path which supports multiple array paths |
command | string | Update command likes composer update |
Test
To use Test into deploy task, make sure that there are test configuration in the source directory.
Key | Type | Description |
---|---|---|
enabled | bool | Enable Test or not |
name | string | The test name for display |
type | string | Test type, support phpunit . |
command | string | The test bootstrap command supported relative filepath such as ./vendor/bin/phpunit |
configuration | string | The test configuration file supported relative filepath such as ./phpunit.xml |
Tests
For multiple test tasks, using array to declare each test options:
Rsync
Key | Type | Description |
---|---|---|
enabled | bool | Enable rsync or not |
params | string | Addition params of rsync command |
timeout | int | Timeout seconds of each rsync connections |
sleepSeconds | int | Seconds waiting of each rsync connections |
identityFile | string | Identity file path for appling rsync |
Commands
Commands provides you to customize deploy tasks with many trigger hooks.
Key | Type | Description |
---|---|---|
init | array | Addition commands triggered at initialization |
before | array | Addition commands triggered before deploying |
after | array | Addition commands triggered after deploying |
Example
-
Copy
project
directory form/var/www/html/
to destination under/var/www/html/test/
: - Copy all files (
*
) form/var/www/html/project/
to destination under/var/www/html/test/
:
USAGE
Interactive Project Select
Non-Interactive Project Select
Skip Flows
You could force to skip flows such as Git and Composer even when you enable then in config.
Revert & Reset back
You could reset git to specified commit by using --git-reset
option when you get trouble after newest release.
This option is same as executing
git reset --hard 79616d
in source project.
IMPLEMENTATION
Assuming project1
is the developing project which you want to deploy.
Developers must has their own site to develop, for example:
In general, you would has stage project1
which the files are same as production:
The purpose is that production files need to be synchronous from stage:
This tool regard stage project as source
, which means production refers to destination
, so the config file could like:
After running this tool to deploy project1
, the stage project's files would execute processes likes git pull
then synchronise to production.
Permissions Handling
1. Local and Remote Users
You could create a user on local for runing Deployer with umask 002
. It will run process by the local user you set even you run Deployer by root:
2. Application File Permissions
Deployer uses rsync
to deploy local source project to remote without --no-perms
, which means that the source files' permission would keep on remote, but the files' owner would re-generate by remote user including root
with --no-owner --no-group
.
On the remote user, you could set the user's default groud ID to www-data
in /etc/passwd
, which the local user generates 664/775
mod files to deploy for remote www-data
access.
For local user,
umask 002
could be set in~/.bashrc
or global. Note that the permission need to apply for source files such as init from Git clone.
CI/CD
Webhook
Deployer provides webhook feature for triggering project deployment by any webhook service such as Gitlab.
To use webhook, you need add webhook setting into the projects you needed in config.inc.php
:
Key | Type | Description |
---|---|---|
enabled | bool | Enable Webhook or not |
provider | string | Webhook provider such as gitlab |
project | string | Provider's project name likes username/project |
token | string | Webhook secret token |
branch | string | Listening branch for push event |
log | bool|string | Enabled log and specify the log file |
PHP Web Setting
Deployer need a user to excute deployment, and the user is usually not the PHP web user.
For PHP-FPM, you could add a new PHP pool socket with the current user setting for the webhook site, for example /etc/php/fpm/pool.d/deployer.conf
:
Then give the new socket to the webhook server setting, for Nginx eaxmple /etc/nginx/site-enabled/webhook
:
After a successful webhook, Deployer would prepare to process while responding the status and the result url for checking the deployment result.
Note: The
PATH
environment variable between Shell and PHP should be set to the same to prevent any unexpected problems.
Gitlab
- Prividor key:
gitlab
According to above Nginx website setting, the webhook URL could be https://webhook.your.com/gitlab
. After setting config.inc.php
and setting up scecret token, you could give a push event to go!
Note: Default setting is listen
release
branch's push event to trigger.
To browse the web page for result log report, enter the same webhook URL with log
and token
parameters to access.
For example: https://webhook.your.com/gitlab?log={project-name}&token={project-token}
ADDITIONS
Rsync without Password:
You can put your local user's SSH public key to destination server user for authorization.
Save Binary Encode File:
While excuting script, if you get the error like Exception: Zend Extension ./deployer does not exist
, you may save the script file with binary encode, which could done by using vim
:
Yii2 Deployment
For yii2-app-advanced
, you need to enable Composer and set yii2 init command in config.inc.php
:
Minify/Uglify by Gulp
1. Install NPM, for Debian/Ubuntu:
2. Install Gulp by NPM
3. Create Gulp Project
4. Set Gulp with packages
Package: gulp-uglify
gulpfile.js
: