Rake-like tool for PHP

Hi everyone.

I am looking to create a layer of automation for a PHP-based project, much like a set of Rake tasks. The project itself is not based on any framework (its a huge proprietary CMS, apparently poorly written in-house), so I cannot go with the flow here. We need to read the configs and classes in PHP, so gulp and rake - my natural choices here - are a no go.

What I need is a good automation tool to write lightweight tasks:

  1. in PHP,
  2. not tied to any framework,
  3. not carrying too much of libraries with it,
  4. not too esoteric (like I’m not really expecting a DSL and everything to be a lambda or even an object, it should rather be as simple to grasp as it gets - procedural approach or even plain PHP is good enough).

I basically need my automation scripts to have a conventional way of launching from command line (so that a necessity for php -xc£h%¥ ./path/to/tool ./path/to/file for each task wouldn’t scare away my team). I need this tool to cd to the root dir of the project, no matter which subfolder I launch the task in (like all automation tools do). I need it to identify and launch the routine I pointed to in command line (sometimes with a few parameters maybe). Sometimes I may need to launch it on the servers where no phpize and stuff like that may ever be available (think corporate environments), so heavy dependencies on Composer or PEAR or similar code repositories are not a good feature - the distribution should be as compact as possible. That’s basically it.

I saw something called phake, but apparently there are a few projects with this name and this alone might confuse the other team in using the tool. Although if you can really recommend that one, I’ll try to use it. Otherwise, I’m all open to your suggestions. Many thanks.

few questions:

  1. if it should be rake like than it should have something like rakefile? for knowing how to access the project config file
  2. i couldn’t figure out what actually you want to achieve from the automate script to do?
  3. if you needs it to be portable you can use phar file

Thanks.

  1. Yes, something like Rakefile is obviously necessary. I’m ok with that, the codebase will not suffer.
  2. One of the typical automation tasks would be to dump the DB (eg to replicate it then on another server). We may have a few different environments (developer’s local machine, Vagrant, staging server, production servers including customer’s ones), so we cannot always use the same mysqldump command. To save some time, we’d better read the config to find MySQL access details and then probably run a shell command with the right keys. The config is conventionally found at the same relative path, so I’d now need the Rake analog that would allow me writing the script itself. (And no, simply parsing it with regexp in Ruby is not ok - configs are complex PHP associative arrays, they may vastly differ by contents from project to project). Naturally, there may be other tasks for this system, like publishing/unpublishing some data, flipping the settings up and down, importing data from the files etc, all done with help of the PHP classes already found in the target system. All of this is basically for the deployment and switching between the phases of development (now your site is a stub - clickety-clack, cooler noise - now its the one you confirmed on the staging).
  3. Phar might be a great idea, thanks.
  1. you could create something like artisan in laravel that receives a command and applies it, so it wouldn’t matter the file you are running it on
  2. you could use a simple json file that holds the config for example which key holds the database info in the config array of the php config file
  3. you could use laravel support package for easy array manipulations

Thanks for suggestions. Duplicating configs is, unfortunately, unacceptable - we need to save some time and effort, not double it. And if only I was using Laravel, Artisan would be naturally in use and there would be no question. But since we may not include Laravel (or anything else as heavy) into those projects, I need a framework-independent tool.

For anyone interested, I found this great document https://github.com/ziadoz/awesome-php, and from the list of Task Runners in it I found this one most fitting my task (no pun intended): http://taskphp.github.io/

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.