Voyager: php artisan db:seed --class=VoyagerDatabaseSeeder is not norking. Throwing erro ReflectionException : Class VoyagerDatabaseSeeder does not exist.

Created on 16 Sep 2019  路  6Comments  路  Source: the-control-group/voyager

Version information

  • Laravel: v5.8.35
  • Voyager: v1.2
  • PHP: 7.1.32-1
  • Database: [type] [version] 10.4.7-MariaDB-1:10.4.7+maria~xenial-log mariadb.org

Description

Following instructions from the official page in the Advanced part when I run php artisan db:seed --class=VoyagerDatabaseSeeder I am getting an error (see below).

Steps To Reproduce

Steps to reproduce the behavior:

  1. Go to 'the official website https://voyager-docs.devdojo.com/getting-started/installation'
  2. After php artisan voyager:install
  3. go to 'Advanced' and run php artisan vendor:publish --provider="TCG\Voyager\VoyagerServiceProvider" AND php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravel5" AND php artisan migrate AND perform tha changes in USER class and route.
  4. When I run the next step php artisan db:seed --class=VoyagerDatabaseSeeder I get the follow error:

```
ReflectionException : Class VoyagerDatabaseSeeder does not exist

at /home/ila/vhosts/voyager2/vendor/laravel/framework/src/Illuminate/Container/Container.php:788
784| if ($concrete instanceof Closure) {
785| return $concrete($this, $this->getLastParameterOverride());
786| }
787|

788| $reflector = new ReflectionClass($concrete);
789|
790| // If the type is not instantiable, the developer is attempting to resolve
791| // an abstract type such as an Interface or Abstract Class and there is
792| // no binding registered for the abstractions so we need to bail out.

Exception trace:

1 ReflectionClass::__construct("VoyagerDatabaseSeeder")
/home/ila/vhosts/voyager2/vendor/laravel/framework/src/Illuminate/Container/Container.php:788

2 Illuminate\Container\Container::build("VoyagerDatabaseSeeder")
/home/ila/vhosts/voyager2/vendor/laravel/framework/src/Illuminate/Container/Container.php:667

Please use the argument -v to see more details.


## Expected behavior
No error. Should have the database initialized with some basic data 

## Note:
If then I run `php artisan voyager:install --with-dummy` everything works good, even the command that was generating the error. Here you have the output:

php artisan voyager:install --with-dummy
Publishing the Voyager assets, database, and config files
Copied Directory [/vendor/tcg/voyager/publishable/database/seeds] To [/database/seeds]
Publishing complete.
Publishing complete.
Migrating the database tables into your application
Nothing to migrate.
Attempting to set Voyager User model as parent to App\User
Dumping the autoloaded files and reloading all new files
Adding Voyager routes to routes/web.php
Seeding data into the database
Publishing dummy content
Copied Directory [/vendor/tcg/voyager/publishable/database/dummy_seeds] To [/database/seeds]
Copied Directory [/vendor/tcg/voyager/publishable/dummy_content] To [/storage/app/public]
Copied Directory [/vendor/tcg/voyager/publishable/database/migrations] To [/database/migrations]
Publishing complete.
Migrating dummy tables
Migrating: 2016_01_01_000000_create_pages_table
Migrated: 2016_01_01_000000_create_pages_table (0.58 seconds)
Migrating: 2016_01_01_000000_create_posts_table
Migrated: 2016_01_01_000000_create_posts_table (0.44 seconds)
Migrating: 2016_02_15_204651_create_categories_table
Migrated: 2016_02_15_204651_create_categories_table (1.37 seconds)
Migrating: 2017_04_11_000000_alter_post_nullable_fields_table
Migrated: 2017_04_11_000000_alter_post_nullable_fields_table (0.62 seconds)
Seeding dummy data
Setting up the hooks
Copied File [/vendor/larapack/hooks/publishable/config/hooks.php] To [/config/hooks.php]
Publishing complete.
Hooks are now ready to use! Go ahead and try to "php artisan hook:install test-hook"
Adding the storage symlink to your public folder
The [public/storage] directory has been linked.
Successfully installed Voyager! Enjoy
ila@ila:~/vhosts/voyager2(master)$ php artisan db:seed --class=VoyagerDatabaseSeeder
Database seeding completed successfully.
```

possible bug

Most helpful comment

Hi, just FYI: I had the same problem and in my case I just had to do a composer dump-autoload before running the seeder.

All 6 comments

You either run php artisan voyager:install or do the advanced steps. Not both.

I resolved this by modifying my DatabaseSeeder to include the content of the VoyagerDatabaseSeeder. Specifically:

use TCG\Voyager\Traits\Seedable;

right bellow class definition:

  use Seedable;

    protected $seedersPath = __DIR__.'/';

inside the run method:

 $this->seed('DataTypesTableSeeder');
        $this->seed('DataRowsTableSeeder');
        $this->seed('MenusTableSeeder');
        $this->seed('MenuItemsTableSeeder');
        $this->seed('RolesTableSeeder');
        $this->seed('PermissionsTableSeeder');
        $this->seed('PermissionRoleTableSeeder');
        $this->seed('SettingsTableSeeder');

Not sure why, but I did the installation manually as I had an already existing application.

Hi, just FYI: I had the same problem and in my case I just had to do a composer dump-autoload before running the seeder.

if you change locale in config/app.php

Return it to

'locale' => 'en',
then
composer dump-autoload
php artisan voyager:install

i still get this error on laravel8.
i installed voyager using 'php artisan voyager:install --with-dummy'
now i need to run only voyager seeder but i get 'Class VoyagerDatabaseSeeder does not exist.'
'composer dump-autoload ' don't solve this problem :(
note: i have 'database/seeds' folder which contain all voyager seeders

i still get this error on laravel8.
i installed voyager using 'php artisan voyager:install --with-dummy'
now i need to run only voyager seeder but i get 'Class VoyagerDatabaseSeeder does not exist.'
'composer dump-autoload ' don't solve this problem :(
note: i have 'database/seeds' folder which contain all voyager seeders

  1. Move all voyager files from seeds to seeders
  2. Add to each of them namespace Database\Seeders;
  3. Edit files VoyagerDatabaseSeeder.php and VoyagerDummyDatabaseSeeder.php - see https://github.com/the-control-group/voyager/pull/5093/files (you need remove use Seedable; and change run method)
  4. Run seed again
Was this page helpful?
0 / 5 - 0 ratings

Related issues

winex01 picture winex01  路  3Comments

IvanBohonosiuk picture IvanBohonosiuk  路  4Comments

iwasherefirst2 picture iwasherefirst2  路  3Comments

craigb88 picture craigb88  路  3Comments

wp-src picture wp-src  路  3Comments