It's not a bad idea, nor a good idea. As long as you follow that process with everything else.
I don't understand why you would need to do that though. Other packages will come with their own namespaces, any any "custom" stuff you do will also have a namespace, so you shouldn't really get any conflicts.
It's not just about conflicts. I generally dislike naming conventions forcing me to use prefixes or suffixes. It's a matter of preference, nothing more :)
What I hope it that namespacing User model doesn't break anything.
Yeah it will break things... If you are doing User::all()
, it'll look for that under the global namespace. If you namespace your models to namespace Models;
, then you need to either do the following in your code:
Change: User::all()
to Models\User::all();
, or you could pull it in directly: use Models\User;
, so you wouldn't have to change every instance of it.
Ehesp, I know how namespacing works in PHP :) I was curious if any external packages or Laravel's logic (like Reminder) call User model as it is.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community