The default HomeController class is defined using
class HomeController extends BaseController {
However, when a resource controller is created via artisan
, the class extends \BaseController
instead of BaseController
. Why is this, and what is the difference?
class TestResourceController extends \BaseController {
There is no difference (in a default installation). The \
simply tells PHP to use the root namespace instead of any other class with the same name but on a different namespace. If you were to create your own class called BaseController, PHP would not know which class to use unless it were explicity defined by the namespace, i.e. MyNamespace\BaseController
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With