PULSE is PHP Build System, which recipes are triggerd with HTTP request on corresponding endpoints.
First, you need to create a php script.
You need to point your http server to it. It will manage routing by itself
automatically.
$ php -S localhost:1337 build.php
In this script you need to create a class that will be extended from Pulse
base class.
Get class exeplar and run doRouting()
method
class Example extended Pulse {
protected function recipe() {
// Here yours code
echo "Hello, Pulse!";
return true;
}
}
header('Content-type: text/plain; charset=utf-8');
$example = Example::getInstance();
$example->doRouting();
Every protected
method will be treated as recipe.
Recipe must return bool to indicate if its failed or not.
Automatically PULSE will create a route with name of your recipe as endpoint and it will call your recipe on HTTP request on this endpoint.
$ curl localhost:1337/recipe
Hello, Pulse!
Also you can run several recipes with this sort of request:
$ curl localhost:1337/build/run/test/foo/bar/baz
Or run every single one with /
endpoint:
$ curl localhost:1337/
If you want to make sure that one recipe runs before another, you should add
$this->runRecipe('firstRecipe');
to your recipe:
class Example extended Pulse {
protected function build() {
// Building binary
}
protected function install() {
$this->runRecipe('build');
// Installing binary
}
}
$ curl localhost:1337/install # Will call `build` first
$ curl localhost:1337/build/install # This works too, `build` will not be called twice
Console
- is a class-wrapper for exec()
to make creation of recipies easier.
Example:
class Example extended Pulse {
protected function build() {
$recipe = (new Console())
->addCmd("gcc test.c -o test")
->run()
->printResults();
return !$recipe->isFailed();
}
}
You can chain command to not execute next commands if one fails:
class Example extended Pulse {
protected function build() {
$recipe = (new Console())
->addCmd("mkdir out/")
->addCmd("gcc test.c -o test")
->addCmd("mv test out/")
->run()
->printResults();
return $recipe->isSuccess();
}
}
Check (build.php)[./build.php] for simple working example of using PULSE with Console.
- Creating recipes
- Starting recipes with HTTP request
- Assuring that some recipes will be called before others
- Handy-ish way to call cosonle comands
- Run all recipes on
/
endpoint - ...