Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
PHP library for executing commands in parallel on multiple remote machines, via SSH
branch: master

This branch is 28 commits behind thephpleague:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
src/League/Grunt
.gitignore
.gruntpwd
.noninteractive
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
LICENSE
README.md
composer.json
composer.lock
phpunit.xml.dist

README.md

Grunt

Build Status Dependencies Status Coverage Status Latest Stable Version Total Downloads

Inspired by Ruby's Capistrano, Grunt is PHP library for executing commands in parallel on multiple remote machines, via SSH. Specifically, this library was written to simplify and automate deployment of PHP applications to distributed environments.

Install

Via Composer

{
    "require": {
        "league/grunt": "1.0.*"
    }
}

Requirement

  • PHP >= 5.3.3
  • libssh2
  • ssh2.so

Assumptions

As opinionated as Ruby's Capistrano, Grunt has very firm ideas about how things ought to be done, and tries to force those ideas on you. Some of the assumptions behind these opinions are:

  • You are using SSH to access the remote servers.
  • You either have the same password to all target machines, or you have public keys in place to allow passwordless access to them.

Do not expect these assumptions to change.

Usage

In general, you'll use Grunt as follows:

  • Create a recipe file (Gruntfile).
  • Use the grunt script to execute your recipe.

From the root folder of your composer-based project, use the grunt script as follows:

vendor/bin/grunt --some_task

By default, the script will look for a file called Gruntfile, which contain hosts information, credential and your tasks. Here the structure of Gruntfile :

<?php

return array(

    'hosts' => array(
        'staging' => 'staging.domain.com'
        'repro' => 'backup.domain.com'
        'production' => 'production.domain.com'
    ),

    'auth' => array(
        'username' => 'grunt',
        'password' => 'hearmyroar',
        'pubkeyfile' => NULL,
        'privkeyfile' => NULL,
        'passphrase' => NULL,
    ),

    'tasks' => array(
        'read_home_dir' => function($g) {
            $g->run('ls');
        },
        'print_php_info' => function($g) {
            $g->run('php -i');
        }
    ),
);

The tasks collection indicates which tasks that available to execute. Based by above recipe, you could run :

vendor/bin/grunt --read_home_dir

Above command will execute ls on all remote machines defined in hosts parameter. You could tell Grunt to run the task on specific host(s) by appending the host nickname right after the task :

vendor/bin/grunt --read_home_dir staging
vendor/bin/grunt --print_php_info staging,production

Grunt also will automatically create some abbreviation for your task. You can do "grunt" to see all the available tasks.

Changelog

See the changelog file

Contributing

Please see CONTRIBUTING for details.

Support

Bugs and feature request are tracked on GitHub

License

Grunt is released under the MIT License. See the bundled LICENSE file for details.

Something went wrong with that request. Please try again.