Skip to content
castor logo

Automate everything. In PHP.

Simply. Efficiently. Elegantly.

๐Ÿš€ TL;DR

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.

  • โœ… 100% PHP โ€” define tasks as simple PHP functions
  • โšก Fast & native โ€” no configuration, no boilerplate
  • ๐Ÿ”ง Provided with a bunch of useful built-in functions
  • ๐Ÿง  Autocompletion & descriptions for each task
  • ๐Ÿงฐ Easy to integrate in your dev workflows

๐Ÿค“ Presentation

Castor is a DX oriented task runner, that is designed to help you automate your development tasks and workflows in a simple and efficient way.

It can be viewed as an alternative to Makefile, Fabric, Invoke, Shell scripts, etc., but it leverages PHP's scripting capabilities and its extensive library ecosystem.

It comes with many features to make your life easier:

  • Seamless parsing of arguments and options, simplifying input handling
  • Autocomplete support for faster and error-free typing
  • A built-in list of useful functions:
    • run(): Runs external processes, enabling seamless integration with external tools
    • io(): Displays beautiful output and interacts with the terminal
    • watch(): Watches files and automatically triggers actions on file modifications
    • fs(): Creates, removes, and manipulates files and directories
    • And even more advanced functions

Note

While Castor hasn't reached v1.0 yet, any API changes are carefully managed with deprecation warnings and compatibility bridges.

๐Ÿง‘โ€๐Ÿ”ฌ Basic usage

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

๐Ÿงช Real-world use cases

  • Run database migrations
  • Deploy your app with one command
  • Manage assets or translations
  • Bootstrap environments
  • Automate internal tools

โ†’ See more examples from the community.

๐Ÿ’ฌ What developers say

"Finally a task runner that feels like PHP. No weird DSL, just functions."
โ€” Every Castor user, probably

"I thought I needed Bash, Make, and half a DevOps degree. Turns out I just needed Castor."
โ€” A surprisingly relieved developer

"We migrated from Make to Castor and nobody cried. That's a win."
โ€” Senior Developer, now less grumpy

๐Ÿค” Why not Robo / Make / Symfony Console?

Because:

  • Robo is too verbose and OOP-heavy
  • Make is not PHP, and is hard to maintain in large projects
  • Symfony Console is a great base โ€” but Castor is built on top of it and gives you superpowers

โ†’ See detailed comparisons in our FAQ

๐Ÿงฐ Get started in 10 seconds

curl "https://castor.jolicode.com/install" | bash

castor

โ†’ Castor can also be installed in other ways (phar, static binaries, Composer), see the installation documentation.

๐Ÿ“š Want more?

Discover more by reading all the docs: