Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between "namespace" and "use" [duplicate]

Tags:

php

laravel

lumen

i have googled the usage of "namespace" and "use" keywords in laravel and ended up with no proper explanation. could someone clearly explain the difference between "namespace" and "use" keywords in laravel?

like image 745
vijay varikol Avatar asked Sep 11 '25 06:09

vijay varikol


1 Answers

Simply, namespaces are like the place of the current class. For example if we have a Person class and it is in app folder, it's namespace will be App\Person. And when you want to use that class you should use it by the keyword use. And that will be use App\Person. It will load that class to your current file. There are plenty of information in the internet about it but if you don't like reading docs (which you should), you can search youtube for a tutorial. (Codecourse channel is good for start)

like image 183
Orkhan Farmanli Avatar answered Sep 13 '25 21:09

Orkhan Farmanli