zoliszabo / rector-docker
A wrapper Composer library for running Rector via Docker.
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Language:Shell
pkg:composer/zoliszabo/rector-docker
This package is auto-updated.
Last update: 2025-12-18 11:32:01 UTC
README
A wrapper Composer library for running Rector via Docker. This package provides a convenient way to use Rector without requiring PHP or Rector to be installed locally on your system.
What is this?
This Composer package provides a rector-docker command that wraps the zoliszabo/rector-docker Docker image, making it easy to run Rector on your PHP projects through a simple command-line interface.
Key Benefits
- No local PHP installation required - Run Rector regardless of your system's PHP version
- Always up-to-date - Uses the latest Rector version from the Docker image
- Cross-platform compatibility - Works on any system that supports Docker
- Intelligent terminal detection - Automatically handles interactive vs non-interactive environments
- Simple integration - Drop-in replacement for the standard
rectorcommand
Installation
Global Installation (Recommended)
Install the package globally to use the rector-docker command from anywhere:
composer global require zoliszabo/rector-docker
Make sure your global Composer bin directory is in your system's PATH. You can find the path with:
composer global config bin-dir --absolute
Project-specific Installation
You can also install it as a development dependency in your project:
composer require --dev zoliszabo/rector-docker
Usage
Once installed, navigate to your project directory and use rector-docker exactly like you would use the regular rector command.
Global Installation Usage
# Process using default rector.php configuration rector-docker process # Process your src directory rector-docker process src # Show available rules rector-docker list-rules # Generate a rector.php configuration file rector-docker init # Dry run to see what would be changed rector-docker process src --dry-run # Process with a specific configuration file rector-docker process src --config custom-rector.php
Project-specific Installation Usage
When installed as a project dependency, prefix commands with vendor/bin/:
# Process using default rector.php configuration vendor/bin/rector-docker process # Process your src directory vendor/bin/rector-docker process src # Or use composer exec composer exec rector-docker process src
All arguments and options are passed directly to Rector running inside the Docker container.
How it Works
The rector-docker command:
- Detects if it's running in an interactive terminal environment
- Mounts your current working directory to
/appinside the Docker container - Runs the appropriate
docker runcommand with the correct flags - Forwards all your arguments to Rector inside the container
Interactive vs Non-Interactive Detection
The script automatically detects the environment:
- Interactive terminals: Uses
-itflags for proper terminal interaction - CI/Scripts: Omits
-itflags to prevent hanging in non-interactive environments
Requirements
- Docker installed and running on your system
- Composer for package installation
Docker Image
This package uses the zoliszabo/rector:latest Docker image, which contains:
- Latest PHP version
- Latest Rector version
- All necessary dependencies
Related Projects
- rector-docker - The underlying Docker image
- Rector - The PHP refactoring tool
License
MIT License. See LICENSE file for details.
Contributing
Issues and pull requests are welcome!