Jonjie's avatar
Level 12

Namespace Hierarchy in PHP

Is there any issue or conflict about the hierarchy of using namespace? I mean if I have 5 imported class, should I have to arrange them? Or is it not necessary?

Is there anything to consider with the example below? Or is there any difference? How about in terms of best practices?

Example:

use App\User;

use App\UserProfile;

use App\Post;

use App\Comments;

VS

use App\Post;

use App\User;

use App\UserProfile;

use App\Comments;

0 likes
2 replies
Cronix's avatar
Cronix
Best Answer
Level 67

It makes no difference in any way and totally up to you. If you notice, laravel's core classes just put them in order of shortest to longest name, just to be cute.

Jonjie's avatar
Level 12

@Cronix Haha Great. Very nice and simple explanation. I'm gonna order it from shortest too so it will be cute haha

Please or to participate in this conversation.