Tuesday, 13 April 2021

Laravel - use APP && use APP make new class

 Since you define a custom namespace libraries\data , the application will try to find the App class in the libraries\data namespace.

If you want to use the laravel App class you need to write this:

 $config = \App::make('config');

Or add use App; at the top of your file like you did with the DB class.


https://stackoverflow.com/questions/27843441/laravel-how-do-you-access-app-object-in-a-custom-class






https://stackoverflow.com/questions/21680795/laravel-4-confused-about-how-to-use-appmake


namespace My;

class NewClass {

    function __construct($id, $title) 
    {
        $this->id    = $id;
        $this->title = $title;
    }
}


$newClass = App::make('My\NewClass', [1, 'test']);

No comments:

Post a Comment