Here is my file structure (Laravel 5.2)
/app/http/middleware/Site.php (file one)
/resources/views/layouts/Automotive/text/DefaultText.php (file two)
I have the first file namespaced at App\Http\Middleware
I want to create a new instance of class DefaultText
(file two) from within file one.
Doing this does not work:
$config_class = "\\Resources\\Views\\Layouts\\Automotive\\Text\\DefaultText";
new $config_class();
And this does not work either:
$config_class = "\\resources\\views\\layouts\\Automotive\\text\\DefaultText";
new $config_class();
In both instances, it states:
Class '\Resources\Views\Layouts\Automotive\Text\DefaultText' not found
How can I do this?
/resources
-folder to be mapped to a namespace in the"autoload": { "psr-4": { ... }}
-part in your composer.json. 2. You haven't added the correct namespace to your DefaultText-class file. 3. You're not using the same casing (the folder names and the namespace must contain the exact same casing). – M. Eriksson