library silex-doctrine-seeders-provider
Seeders for Silex
ericjeker/silex-doctrine-seeders-provider
Seeders for Silex
- Sunday, October 1, 2017
- by ejeker
- Repository
- 1 Watchers
- 0 Stars
- 1 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 1 Versions
- 0 % Grown
silex-doctrine-seeders-provider
Provider to allow seeders in your Silex project., (*1)
Installation
Create a console.php
file at the root of your application directory and add this content:, (*2)
// create the console application
$console = new Application();
// register doctrine DBAL seeder service provider
$app->register(new DoctrineSeedersProvider($console), [
'seeders.directory' => __DIR__ . '/database/seeders',
'seeders.name' => 'App Seeder',
'seeders.namespace' => 'App\Seeders'
]);
$console->run();`
Create a seeder class
<?php
namespace App\Seeders;
use Wowww\Silex\Provider\AbstractSeeder;
class UserSeeder extends AbstractSeeder
{
public function seed()
{
// ...
// you can access app with $this->app
// if your seeder return an array it is considered as sub-seeders
return [
ArticleSeeder::class,
RegistrationsSeeder::class
];
}
}
Run the seeders
php console.php seeders:execute