11/8/2011 - 7:27 AM

Brainstorming a Capistrano-like tool for PHP deployments.

Brainstorming a Capistrano-like tool for PHP deployments.

 * Toying with an idea of developing a Capistrano-like tool in PHP.
 * Deployment namespaces and tasks are dynamically handled using __call(). "Description" would use late static 
 * binding to determine which task it was run inside of. Collection is like an object-oriented array that has 
 * a bunch of niceties from Ruby and JavaScript.
 * Designed to simultaneously push commands and deploy code to all machines in a cluster at once, using
 * Capistrano's method of generating a symlink farm so that deployment/rollback is easy and consistent.

# The PHP namespace that all deployment tasks are executed with.
namespace Deployment
    # Import and alias PHP namespaces.
    use Push\Command\System,

    # New deployment namespace
        #$ push setup:install to {role}
            # Special method to set the task's description.
            Description::set('Upgrade and install YUM packages.');

            # Collect the names of the YUM packages to install on the remote system.
            $package_list = new Collection("svn", "ruby-devel", "fuse", "fuse-devel", "gcc", "gcc-c++", "python-devel",
                "libxml2-devel", "curl-devel", "libtool", "kernel-devel", "openssl-devel", "libxslt-devel", "python-pycurl",
                "python-simplejson", "MySQL-python", "python-setuptools", "python-setuptools-devel");

            # Sort the package names and output them to the display one-by-one.
                System::log("* " . $package);

            # Execute the following commands on the remote system.
            System::remote('yum check-update');
            System::remote('yum -y upgrade');
            System::remote('yum -y install ' . $package_list->join(' '));

        #$ push setup:development to {role}
            Description::set('Configure the local machine for development.');

            System::local('sudo port install php5 php5-apc php5-curl');
            System::local('php --version');