Did you mean to include the Vendor (and Package) namespace?
Database seeders within package
Hello, guys!
I'm working on a small reusable package and one part of it - to publish some seeds. I was wanted to automate this task, but was surprised that couple of old ways to solve it were removed in L5.
Is there is a way to do call seeds from package without manually copying them to the applications folder? I've tried latest 5.1.x version for the tests.
There is a topic how to deal with package seeds, but it's one year old and it seems to be outdated for current release.
I've tried to add namespace to my seeds and in package's composer.json file, but no luck, Laravel won't see and use them:
"autoload": {
"psr-4": {
"Vendor\\Package\\": "src/",
"Vendor\\Package\\Database\\Seeds": "database/seeds/"
}
},
composer dump-autoload
php artisan db:seed --class="Vendor\Package\Database\Seeds\PackageSeeder"
Output:
[ReflectionException] Class Vendor\Package\Database\Seeds\PackageSeeder does not exist
After that I've tried to call it right from the default DatabaseSeeder application class:
<?php
use Vendor\Package\Database\Seeds\PackageSeeder;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
public function run()
{
$this->call(PackageSeeder::class);
}
}
Same result :'(
Please or to participate in this conversation.