Is there a way to run the Laravel 5 seeder from within PHP rather than from the command line. The hosting I am using doesn't allow me to use the command line. Just to confirm I want to do the equivalent of this but in my app code:
php artisan db:seed
Laravel Seeding Creating a Seeder To create seeders, you may use the make:seeder Artisan command. All seeders generated will be placed in the database/seeds directory. Generated seeders will contain one method: run . You may insert data into your database in this method.
@nhayder you can just new up the seeder inside your controller and get any public properties or run the run() method. $seeder = new \Database\Seeds\WantedSeeder(); $seeder->run();
You can use the following method:
Artisan::call('db:seed');
To get the output of the last run command, you can use:
Artisan::output();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With