jolicode / castor
DX oriented task runner and command launcher built with PHP
Installs: 35 844
Dependents: 2
Suggesters: 0
Security: 0
Stars: 427
Watchers: 16
Forks: 21
Open Issues: 6
Type:project
Requires
- php: >=8.1
- composer/composer: ^2.8.3
- jolicode/jolinotif: ^3.0.0
- jolicode/php-os-helper: ^0.1.0
- monolog/monolog: ^3.8
- nikic/php-parser: ^v5.3.1
- phpstan/phpdoc-parser: ^1.33
- spatie/ssh: ^1.12.0
- symfony/cache: ^6.4.14
- symfony/config: ^6.4.14
- symfony/console: ^6.4.15
- symfony/dependency-injection: ^6.4.15
- symfony/deprecation-contracts: ^3.5
- symfony/dotenv: ^6.4.13
- symfony/error-handler: ^6.4.14
- symfony/expression-language: ^6.4.13
- symfony/filesystem: ^6.4.13
- symfony/finder: ^6.4.13
- symfony/http-client: ^6.4.15
- symfony/monolog-bridge: ^6.4.13
- symfony/process: ^6.4.15
- symfony/string: ^6.4.15
- symfony/translation-contracts: ^3.5.0
- symfony/var-dumper: ^6.4.15
- symfony/yaml: ^6.4.13
Requires (Dev)
- phpunit/php-code-coverage: ^9.2.32
- symfony/phpunit-bridge: ^6.4.13
Conflicts
- symfony/config: 6.4.13
- symfony/console: 6.4.3
This package is auto-updated.
Last update: 2024-12-10 14:20:31 UTC
README
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:
- 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()
: 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- 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: