watoki / stepper
A minimal migration tool for PHP.
Installs: 1 091
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/watoki/stepper
Requires
- php: >=5.4
- watoki/cli: *
- watoki/factory: *
- watoki/smokey: *
Requires (Dev)
- watoki/scrut: *
This package is not auto-updated.
Last update: 2025-10-11 19:54:16 UTC
README
stepper is a minimalistic migration tool.
Usage
In order to use stepper, you need at least one Step defining what should happen when the the Step is executed and also whether and how it can be undone.
class MyFirstStep implements Step {
public function up() {
// does something
}
public function down() {
// undoes something
}
public function canBeUndone() {
return true;
}
public function next() {}
}
With this one Step and a file (e.g. migration.state) to store the current state in, you can start the Stepper:
$app = new CliApplication(new StepperCommand(new StepOne(), 'migration.state'));
$app->run();
That's it. You can now execute the Step with php myScript.php. If you add a second Step later, make sure that the first Step
returns it in it's next method:
public function next() {
return new AnotherStep();
}
If you run php myScript.php now, only AnotherStep gets executed since the fact that the first Step already has been executed
has been saved in migration.state.
If you want to revert whatever AnotherStep did you can run php myScript.php --to=MyFirstStep which will execute the down function
of AnotherStep. This won't work if AnotherStep::canBeUndone returns false.
Documentation
For a detailed documentation, check out the test suite.