Laravel - Namespaces

Laravel - Namespaces

Namespaces can be defined as a class of elements where each element has a unique name for that associated class. Can be used in conjunction with elements of other classes.

Namespace declaration

The use keyword allows developers to shorten the namespace.

use <namespace-name>;

The default namespace used in Laravel is App, however the user can change the namespace to suit the web application. Creating a custom namespace with the artisan command is mentioned as follows:

php artisan app:name SocialNet

The generated namespace can include various functions that can be used in controllers and various classes.