Sometimes, there are pieces of software, which are unfairly forgotten. Let’s talk about one these.
Often, while working on software projects, one finds, that there are repetitive tasks, which would be much easier to deal with, if automated. In the C/Unix world, this task is often solved by Make, Java programmers prefer Apache Ant, Ruby programmers use Rake. The fact, which is not commonly known, is, that PHP also has such instrument, and it is called Pake. It was originally created by authors of Symfony framework. Unfortunately, they never wrote any documentation, which killed adoption rates.
To start automating something, you need to create Pakefile.php in the root-directory of your project, define some tasks inside and run them with “pake taskname” from command-line. The good news is, that tasks are defined in PHP language and syntax is quite simple:
pake_desc(‘FOO task’);
pake_task(‘foo’, ‘bar’);
pake_desc(‘BAR task’);
pake_task(‘bar’, ‘baz’);
pake_desc(‘BAZ task’);
pake_task(‘baz’);
pake_alias(‘default’, ‘foo’); // marking foo as default task
function run_foo($task, $args)
{
echo "foo\n";
}
function run_bar($task, $args)
{
echo "bar\n";
}
function run_baz($task, $args)
{
echo "baz\n";
}
I defined 3 rules, gave them descriptions and specified dependencies. Additionally, I specifed default rule. Now, we can play with this a bit. Create file with this contents, save it somewhere, and point your terminal to the same directory.
> pake
baz
bar
foo
What happened? Pake looks for “default” task in the pakefile. We defined “foo” as default. Pake found out, that foo depends on bar, and bar depends on baz. So, Pake runs “baz”, then “bar” and then, finally, “foo”. That is as simple as it can be.
Pake has builtin support for basic file-operations (pake_mkdirs(), pake_copy(), pake_rename(), pake_remove()), which are the powered-up versions of php’s filesystem-functions, templating (pake_replace_tokens()), directory-mirroring (pake_mirror()) and runners for creating PEAR-packages, Phing-commands and Simpletest.
Pake project wasn’t maintained for a while, so I decided to give it a spin (as there is a good chance, that I will be able to use it for my current projects). I imported it’s version history to GitHub. You can find latest version here: http://github.com/indeyets/pake
My plan is to add some generally usable helpers to current branch, write some documentation and then to start work on Pake2 which would use all new features of PHP-5.3 (namespaces, closures, rich SPL).
Git-project is a source for creating pear-package. To build one use the following command:
> php bin/pake.php release 1.1.0a1
it will create “pake-1.1.0a1.tgz” file in the same directory. You can install it with the following command:
> pear install -f pake-1.1.0a1.tgz
If you want to grab a prebuild pear-package of pake, you can do it here

[...] Zakhlestins has posted about a build system created by developers of the Symfony framework as PHP’s answer to Make and Rake – Pake. [...]
[...] Zakhlestins has posted about a build system created by developers of the Symfony framework as PHP’s answer to Make and Rake – Pake. [...]
Hi.
What are the differences/pro/cons against Phing?
Thanx.
1) Phing is XML-based, like Ant. Pake is PHP-based (syntax is simplier)
2) Phing has weird parameterization when you need to specify some addotional flags, Pake let's you do this as simple as you need
3) Pake can use Phing for it's subtasks (while adding a nice wrapper around them)
Well, yes, PHP already has a tool that parallels Ant and Rake. But it's not Pake, it's Phing. It's much older, well documented, has a substantial community, is in active development, and has a wide collection of pluggable tasks. It's not very reasonable to use Pake, actually. Not only it's not documented, it's not even actively developed and it'll be dropped (maybe it already is) by Symfony. So, as much as I hate that counter-intuitive hacking of those XMLs, Pake is not a viable option, I'm afraid.
If your continue the project and make something out of it, then great, I'd like to see that. But until then, please don't recommend it to us as if it was on par with other build tools.
Well, my idea is to raise interest, to potentially good solution. And, yes, I am going to start medical procedures and force the patient to live long and happily
By the way, as I mentioned earlier, pake is useful even as a wrapper for phing
Well, I'm looking forward to see what you make of it. As I mentioned earlier, I don't like Phing very much, so you have my support.
brrr… this bloated Phing with all those XMLs. Pake is more PHP friendly. You have my support too !
Good to see someone picking Pake up. I have been thinking about doing the same thing. One problem with Pake is that it got absorbed into Symfony, which means that it never grew any further. In part, I think that is intentional from Fabien, since it is one of the things that makes Symfony stand out amongst other frameworks. It's a pity though; PHP could do well with a standard tool for this, rather than something that is tied to each individual framework.
Good stuff.
The symfony project is making a good attempt at peeling off some of the tools into stand alone components:
http://components.symfony-project.org/
Thanks Duane. I was not aware of that effort.
This looks cool. I think I will try this for a project.
[...] This post was Twitted by onwhitespace [...]
[...] by Planet PHP, read more at the original (another 1495 bytes) var addthis_pub = ''; var addthis_language = 'en';var addthis_options = [...]
Great work!
Alexey, but why Pake wasn’t maintained? As I know, Pake is often used in Symfony (subproject? Same developers?), and Symfony maintained very well. I thought, Symfony guys should support this project…
Symfony had Pake as independent project in 1.0.x days. After that, as far as I understand, they integrated it with their core much more tightly, so it is not possible to use it separately, anymore.
Personally I use phing, which has a more or less good documentation but it is little diffused too.
almost everybody does
Phing was mentioned several times in comments already. Pake is quite useful even as a wrapper around phing-tasks. It is possible to get something more user-friendly this way.
Is there svn support for this? Or just git? One of the reasons I've never personally ventured into any established PHP build systems is that they're so convoluted. I actually find it a lot easier to use PHP's exec() to export any number of svn repos and rsync them into place.
I recently added support for SVN, Git and rsync
something like this:
pakeSubversion::export($repo_url, $local_path);
pakeRSync::sync_to_server($local_path, 'your.server.com', $remote_path);
in case of pakeRSync you can specify array of paths as $local_path and pake will put all of them in $remote_path