Support the ongoing development of Laravel.io →
posted 10 years ago
Architecture
Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

kokokurak kokokurak Joined 21 Aug 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.