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
You can use the following method:
To get the output of the last run command, you can use:
You can also call directly the Seeder class if needed.
Just make sure you did a composer dump-autoload if you created your seeder manually.
From there code is very straightforward :
$seeder = new YourSeederClass(); $seeder->run();