🦫 DX oriented task runner and command launcher built with PHP.
Castor is a lightweight, modern task runner for PHP.
No need for Bash, Makefiles or YAML.
Write your automation scripts in PHP, run them from the CLI.
Castor is a DX-oriented task runner built in PHP featuring a range of functions for common task processing.
It can be viewed as an alternative to Makefile, Fabric, Invoke, Shell scripts,
etc., but it leverages PHP’s scripting capabilities and extensive library ecosystem.
It comes with many features to make your life easier:
run()
: Run external processes, enabling seamless integration with external toolsio()
: Display beautiful output and interacts with the terminalwatch()
: Watch files and automatically triggers actions on file modificationsfs()
: Create, remove, and manipulate files and directories[!NOTE]
While Castor hasn’t reached v1.0 yet, any API changes are carefully managed with
deprecation warnings and compatibility bridges.
In Castor, tasks are set up as typical PHP functions marked with the #[AsTask()]
attribute in a castor.php
file.
These tasks can run any PHP code but also make use of various functions for standard operations that come pre-packaged with Castor.
For example, the following castor.php file:
use Castor\Attribute\AsTask;
#[AsTask()]
function hello(): void
{
echo 'Hello from castor';
}
Will expose a hello
task that you can run with castor hello
:
$ castor greetings:hello
Hello from castor
Then, you can go wild and create more complex tasks:
#[AsTask(description: 'Clean the infrastructure (remove container, volume, networks)')]
function destroy(bool $force = false)
{
if (!$force) {
io()->warning('This will permanently remove all containers, volumes, networks... created for this project.');
io()->comment('You can use the --force option to avoid this confirmation.');
if (!io()->confirm('Are you sure?', false)) {
io()->comment('Aborted.');
return;
}
}
run('docker-compose down -v --remove-orphans --volumes --rmi=local');
notify('The infrastructure has been destroyed.')
}
→ Want to see basic usages and main features of Castor? Read the Getting started documentation
Because:
→ See detailed comparisons in our FAQ
curl "https://castor.jolicode.com/install" | bash
castor
→ Castor can also be installed in other ways (phar, static binaries, Composer), see the installation documentation.
Discover more by reading the docs: