Giter VIP home page Giter VIP logo

castor's Introduction

castor logo

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 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

Castor is still in early development, and the API is not stable yet. Even if it is unlikely, it is still possible that it will change in the future.

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:

<?php

namespace greetings;

use Castor\Attribute\AsTask;
use function Castor\io;

#[AsTask()]
function hello(): void
{
    io()->writeln('Hello from castor');
}

Will expose a greetings:hello task that you can run with castor greetings: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.')
}

If you want to read more about usage, you can read the basic usage documentation, or watch some examples.

Installation

With the installer

Tip

This is the recommended way to install Castor on Linux and macOS. It requires PHP >= 8.1.

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

There are other ways to install Castor, please refer to the documentation.

Further documentation

Discover more by reading the docs:

castor's People

Contributors

lyrixx avatar pyrech avatar joelwurtz avatar theod02 avatar tigitz avatar tucksaun avatar damienalexandre avatar yanncharlou-cleverage avatar korbeil avatar thedomeffm avatar ruudk avatar drupol avatar ptondereau avatar welcomattic avatar jeckel avatar arnolem avatar alexislefebvre avatar ternel avatar jorickpepin avatar nispeon avatar gromnan avatar marionleherisson avatar qboot avatar seblours avatar tacman avatar ceciledelmon avatar dantleech avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.