Idephix

Ideato automation and deploy tool

Download .phar View on GitHub

Welcome to Idephix.

curl http://getidephix.com/idephix.phar > idephix.phar

Idephix is a PHP automation tool useful to perform remote and local tasks. It can be used to deploy applications, rotate logs, synchronize data repository across server or create a build system. The choice is up to you. Idephix is still in alpha, so things will change. You can report issues and submit PRs (greatly appreciated :-)) on the github repo

Install Idephix

You can choose to install idephix where you prefer. Idephix will use (or create for you) the configuration file in the corrent path.

  • Change into a directory in your path like cd /usr/local/bin
  • Get Idephix curl http://getidephix.com/idephix.phar > idephix.phar
  • Make the phar executable chmod a+x idephix.phar
  • Change into a project directory cd /path/to/my/project
  • Create a new idxfile.php using idephix.phar init-idx-file
  • Define your tasks in idxfile.php
  • Use idephix as you normally would idephix.phar
  • Optionally you can rename the idephix.phar to idx to make it easier

Idephix ships with some predefined commands:

$ ./idephix.phar
  ___    _            _     _
 |_ _|__| | ___ _ __ | |__ (_)_  __
  | |/ _` |/ _ \ '_ \| '_ \| \ \/ /
  | | (_| |  __/ |_) | | | | |>  <
 |___\__,_|\___| .__/|_| |_|_/_/\_\
               |_|
Idephix version @package_version@

Usage:
  [options] command [arguments]

Options:
  --help           -h Display this help message.
  --quiet          -q Do not output any message.
  --verbose        -v Increase verbosity of messages.
  --version        -V Display this application version.
  --ansi              Force ANSI output.
  --no-ansi           Disable ANSI output.
  --no-interaction -n Do not ask any interactive question.
  --env               Set remote environment.

Available commands:
  help              Displays help for a command
  init-idx-file     Create an example idxfile.php
  list              Lists commands
  selfupdate        Donwload and update Idephix

Usage example

You can create idxfile.php by hand:

<?php

/* /your/project/path/idxfile.php */

use Idephix\Idephix;
use Idephix\Extension\Deploy\Deploy;
use Idephix\Extension\PHPUnit\PHPUnit;

$localBaseDir = __DIR__;
$sshParams = array(
  'user' => 'myuser',
);

$targets = array(
  'prod' => array(
    'hosts' => array('127.0.0.1'),
    'ssh_params' => $sshParams,
    'deploy' => array(
      'local_base_dir' => $localBaseDir,
      'remote_base_dir' => "/var/www/myfantasticserver/",
      // 'rsync_exclude_file' => 'rsync_exclude.txt'
      // 'rsync_include_file' => 'rsync_include.txt'
      // 'migrations' => true
      // 'strategy' => 'Copy'
    ),
  ),
);

$idx = new Idephix($targets);

$idx->
  /**
   * Symfony2 basic deploy
   */
  add('sf2:deploy',
    function($go = false) use ($idx)
    {
      if (!$go) {
        echo "\nDry Run...\n";
      }
      $idx->deploySF2Copy($go);
    })->
  /**
   * Build your Symfony project after you have downloaded it for the first time
   */
  add('build:fromscratch',
    function () use ($idx)
    {
      if (!file_exists(__DIR__.'/composer.phar')) {
        $idx->output->writeln("Downloading composer.phar ...");
        shell_exec('curl -sS https://getcomposer.org/installer | php');
      }

      passthru("php composer.phar update");
      passthru("./app/console doctrine:schema:update --force");
      $idx->runTask('asset:install');
      passthru("./app/console cache:clear --env=dev");
      passthru("./app/console cache:clear --env=test");
      //$idx->runTask('test:run');
    })->
  /**
   * Symfony2 installing assets and running assetic command
   */
  add('asset:install',
    function () use ($idx)
    {
      passthru("app/console assets:install web");
      passthru("app/console assetic:dump");
    })->
  /**
   * run phpunit tests
   */
  add('test:run',
    function () use ($idx)
    {
      $idx->runPhpUnit('-c app/');
    })
  ;

$idx->addLibrary('deploy', new Deploy());
$idx->addLibrary('phpunit', new PHPUnit());

$idx->run();

run idephix.phar to execute the script and get the commands list

$ ./idephix.phar
  ___    _            _     _
 |_ _|__| | ___ _ __ | |__ (_)_  __
  | |/ _` |/ _ \ '_ \| '_ \| \ \/ /
  | | (_| |  __/ |_) | | | | |>  <
 |___\__,_|\___| .__/|_| |_|_/_/\_\
               |_|
Idephix version @package_version@

Usage:
  [options] command [arguments]

Options:
  --help           -h Display this help message.
  --quiet          -q Do not output any message.
  --verbose        -v Increase verbosity of messages.
  --version        -V Display this application version.
  --ansi              Force ANSI output.
  --no-ansi           Disable ANSI output.
  --no-interaction -n Do not ask any interactive question.
  --env               Set remote environment.

Available commands:
  help              Displays help for a command
  init-idx-file     Create an example idxfile.php
  list              Lists commands
  selfupdate        Donwload and update Idephix
myscript
  myscript:local-touch	Execute the touch of a file named in input locally
  myscript:remote-touch	Execute the touch of a file named in input in a remote server
  myscript:touch        Execute the remote and local touch

then you can choose to execute a standard options or the one defined in the idxfile.php

$ ./idephix.phar myscript:local-touch myFile.txt

More examples to be published soon...

Requirements

PHP 5.3.2 or above, at least 5.3.12 recommended

Authors

Manuel 'Kea' Baldassarri, Michele 'Orso' Orselli, Filippo De Santis and other contributors

License

Idephix is mantained by ideato, licensed under the MIT License - see the LICENSE file for details

Support or Contact

Having trouble with Idephix? Check out the documentation or ask us for direct support to info@ideato.it and we’ll help you sort it out.