Published under Laravel.
"cannot declare class because the name is already in use"
This can be an annoying error to track down.
The first thing to look for is that you do not have more than one of the same class defined in the namespace.
If that doesn't solve your problem, then you need to start hunting. Make sure you clear your compiled cache too:
In my case, I had renamed a Laravel migration file that was published from Laravel Cashier. This turned out to be a problem. Here's how it breaks down:
So now we have an issue. Both migration files (my own codebase, and Laravel Cashier's version), have different file names, but they both still have the same class name:
You have two options:
Don't rename the original migration files
If you must rename the migration, also make sure to rename the class too!
Subscribe to my newsletter to know when I publish more content in the future.