deployer/README.md

139 lines
3.3 KiB
Markdown
Raw Normal View History

2013-11-16 18:08:52 +04:00
[![Build Status](https://travis-ci.org/elfet/deployer.png?branch=master)](https://travis-ci.org/elfet/deployer)
2013-07-11 18:40:44 +04:00
Introduction
------------
There are a lot of deployment tools, even in php. But none of them are simple and functional like Deployer.
2013-07-13 14:33:11 +04:00
Here is simple example of deployment script (deploy.php):
```php
require 'deployer.phar';
$key = '~/.ssh/id_rsa';
task('prod_server', function () use ($key) {
connect('prod.ssh.domain.com', 'user', $key);
2013-07-13 14:33:11 +04:00
});
task('test_server', function () use ($key) {
connect('test.ssh.domain.com', 'user', $key);
2013-07-13 14:33:11 +04:00
});
task('upload', function () {
upload(__DIR__, '/home/domain.com');
});
task('clear', function () {
run('php bin/clear');
});
task('prod', 'Deploy on production.', ['prod_server', 'upload', 'clear']);
task('test', 'Deploy on test server.', ['test_server', 'upload', 'clear']);
2013-07-13 14:33:11 +04:00
start();
```
Now you can run `php deploy.php prod` command to deploy on production server.
[Here](example/symfony.php) you can see Symfony deployment example script.
2013-07-11 18:40:44 +04:00
Requirements
------------
Deployer is only supported on PHP 5.3.3 and up.
Installation
------------
2013-07-13 14:33:11 +04:00
You can download [deployer as phar](http://deployer.in/deployer.phar) archive or you can use composer:
2013-07-11 18:40:44 +04:00
```
"require": {
2013-07-13 14:33:11 +04:00
"elfet/deployer": "dev-master@dev"
2013-07-11 18:40:44 +04:00
}
```
2013-07-13 14:33:11 +04:00
If you use phar version, simple require it in your script:
```php
require 'deployer.phar';
```
If your use composer version, require your autoload file and call deployer function.
```php
require 'vendor/autoload.php';
deployer();
```
2013-07-11 18:40:44 +04:00
Development
-----------
This project is still in development. I want to invite developers to join the development.
2013-07-13 14:33:11 +04:00
There are a lot of things needs to be implemented:
2013-07-11 18:40:44 +04:00
* Add rsync support if available.
* Add pecl ss2 extension support if available.
* Write better documentation and tests.
2013-07-11 19:00:21 +04:00
Documentation
-------------
2013-07-13 14:33:11 +04:00
```php
2013-07-11 19:00:21 +04:00
task(name, [description], callback)
```
* name - required, you can run tasks from CLI.
2013-07-13 14:33:11 +04:00
* description - optional, describe your task. If `false` this task will be private and does not available from CLI.
2013-07-11 19:00:21 +04:00
* callback - closure or array of tasks.
2013-07-13 14:33:11 +04:00
```php
2013-11-12 23:01:43 +04:00
connect(server, user, key, group = null)
2013-07-11 19:00:21 +04:00
```
2013-11-12 23:01:43 +04:00
Connect to `server`, login as `user` with `key` which is password or RSA key and add to `group`.
2013-07-11 19:00:21 +04:00
2013-07-13 14:33:11 +04:00
```php
2013-07-11 19:00:21 +04:00
rsa(path, [password])
```
Can be used as `key` in `connect` function with `path` to your RSA key (~/.ssh/id_rsa) and `password` of your key.
2013-07-13 14:33:11 +04:00
```php
cd(path)
2013-07-11 19:00:21 +04:00
```
Change remote directory to given `path`.
2013-07-11 19:00:21 +04:00
2013-07-13 14:33:11 +04:00
```php
upload(from, to)
2013-07-11 19:00:21 +04:00
```
Upload local files or directories `from` to remote `to`.
2013-07-11 19:00:21 +04:00
2013-07-13 14:33:11 +04:00
```php
2013-07-11 19:00:21 +04:00
ignore(array)
```
Ignore this files while uploading directories. `array` of string with `*` patterns.
2013-07-13 14:33:11 +04:00
```php
run(command)
2013-07-11 19:00:21 +04:00
```
Run `command` in directory provided by `cd` function.
2013-07-11 19:00:21 +04:00
2013-10-26 22:02:15 +04:00
```php
runLocally(command)
```
Run `command` locally.
2013-07-13 14:33:11 +04:00
```php
2013-07-11 19:04:08 +04:00
writeln(message)
write(message)
```
Write `message` with/without new line.
```php
group(group_name, function () {
// run, cd, upload and ext commands
})
```
Run commands `run`, `cd`, `upload` only for group connections.
2013-07-11 19:04:08 +04:00
If your do not want include functions, you can use methods:
```php
2013-07-13 14:33:11 +04:00
$tool = deployer(false);
2013-07-11 19:04:08 +04:00
$tool->task('connect', function () use ($tool) {
$tool->connect('ssh.domain.com', 'user', 'password');
});
```
Every function is alias to `Deployer\Tool` methods.
2013-07-11 19:00:21 +04:00
License
-------
2013-07-13 14:33:11 +04:00
Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php