DeschutesDesignGroupLLC / wordpress-plugin-template

Start here to begin creating a Wordpress plugin.
https://www.deschutesdesigngroup.com
MIT License
7 stars 2 forks source link

command wp acorn db:seed not working as expected #1

Closed bedirhandev closed 2 weeks ago

bedirhandev commented 3 weeks ago

Hello,

I noticed when using the command "wp acorn db:seed" the following error occurs:

INFO  Seeding database.

In Container.php line 891:

  Target class [DatabaseSeeder] does not exist.

In Container.php line 889:

  Class "DatabaseSeeder" does not exist

This command is executed from WSL2 on Windows, other commands such as "wp acorn make:migration" works.

How could this be resolved?

bedirhandev commented 3 weeks ago

I have a workaround as a solution but would be nice to have a proper solution:

In the PluginModelFactory file a namespace is changed to "Database\Factories" and also in the DatabaseSeeder file a namespace is changed to "Database\Seeder".

I expected that in the composer.json file in the section "autoload", "psr-4" the lines would solve this issue.:

  "WordpressPluginTemplate\\Database\\Factories\\": "src/database/factories/",
  "WordpressPluginTemplate\\Database\\Seeders\\": "src/database/seeders/",

Now running the command: wp acorn db:seed works as expected. It could be a namespace issue.

jonerickson commented 2 weeks ago

I have updated the documentation on how to perform the seeding. Because the namespaces difference from default Laravel convention, you have to pass in the seeder class so it knows what to use. I have pushed an update as the factories were not resolving as well. See #4