Laravel Inspired Devtools for Phalcon
https://github.com/zachleigh/yarak
Currently, I've got migrations, model factories, database seeding, and user defined custom commands done. Here's a run down of each feature:
Migrations
- Migration files are in a single directory and are timestamped to keep them in order.
- Just like the migrations in the official devtools, migrations use Phalcon's Database Abstraction Layer to interact with the database.
- Migrations can be rolled back in steps.
- Migrations can be used to reset and refresh the database.
Model Factories
- Model factories allow you to create model instances and persist them on the fly. If you want three test users, simply do this:
factory(Users::class, 3)->create();
- Factories make use of the Faker library to create sample test data.
- You can create multiple factories for a single model and name them. This is very useful if you want to do something specific like create an admin user and then a guest user.
- Default model factory logic can be overridden to create custom models that don't use Faker.
factory(Users::class)->create(["username" => "bobsmith"]);
Database Seeding
- The database seeding component allows you to instantly create test data or even seed a production database.
- Seeders can call other seeders so you can better organize seeding logic.
- Integrated with the migration component to allow seemless database reset. Want to rollback everything and re-seed? No problem:
php yarak migrate --refresh --seed
Custom Commands
- You can create your own commands that can be called just like any other Yarak command.
- Yarak commands wrap around the Symfony console component and allow you to write commands in a simple manner. Here's an example command definition:
protected $signature = "spell {word=example} {--b|backwards}";
- Call commands exactly as you write them:
php yarak spell myWord --backwards
I'd love to get some feedback on it. If there's anything you think I can do better or have suggestions, please let me know!