byjg / scriptify
Transform any PHP class into an executable script callable from the command line without changes or refactoring.
6.0.0
2025-11-25 00:12 UTC
Requires
- php: >=8.3 <8.6
- ext-readline: *
- byjg/jinja-php: ^6.0
- symfony/console: ^5.4|^6.2|^7.0
Requires (Dev)
- ext-posix: *
- byjg/restserver: ^6.0
- phpunit/phpunit: ^10.5|^11.5
- vimeo/psalm: ^5.9|^6.13
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-25 23:50:32 UTC
README
| sidebar_key | scriptify | ||
|---|---|---|---|
| sidebar_category | infrastructure | ||
| tags |
|
Scriptify: PHP Methods as Commands and Services
Run any existing PHP method from the command line, or install it as a system service, without writing a command class.
Why
To call your code from a shell, a cron job or a daemon, frameworks make you write a command class for each task: parse the arguments, build the dependencies, call the method. The method you wanted to run already exists.
Scriptify calls it directly:
scriptify run "App/Service/Report::rebuild" --arg 2026-10 # once, from the shell scriptify install --template=crond nightly-report \ --class "App/Service/Report::rebuild" --rootdir /srv/app # as a cron job or systemd service
- No glue code. The arguments are passed to the method's parameters, and with a PSR-11 container the class gets its constructor dependencies.
- From shell to service in one step.
installwrites the systemd, cron, upstart or init.d service with the full command line. - A command line for your app.
Launchermaps short names (php app report:rebuild) to methods, andscriptify terminalopens a REPL with your autoloader.
Features
Scriptify allows you to:
- Call any PHP method from the command line
- Install PHP classes/methods as system services (daemon, cron, etc.)
- Call REST endpoints from shell scripts
- Open an interactive PHP terminal with your project's autoloader
- Pass environment variables to your scripts
Documentation
- Call a PHP method from the command line
- Resolve classes through a PSR-11 container
- Give your application a command line: Launcher
- Install a PHP class/method as a service
- Call a REST endpoint from the command line
- Interactive PHP terminal
- Show method documentation
- Environment variables
- Play with the service
Installation
Scriptify does not need to be associated with your PHP project.
Install Locally (Recommended)
composer require "byjg/scriptify"
Install Globally
composer global require "byjg/scriptify" sudo ln -s /root/.composer/vendor/bin/scriptify /usr/local/bin/scriptify # If you want to share this installation with other users, consider using: chmod a+x /root # Note: The root directory will remain unreadable for them, but they can execute scriptify
Running Tests
vendor/bin/phpunit