Friday, May 18, 2018

Laravel 5.6 and reflection not finding class - development

Laravel 5.6 and reflection not finding class

I’m building a package in Laravel 5.6, im very new to building packages so im cutting and copying and learning as I go. so far so good, except i have run into a little issue.

My main package class is in packages/vendor/packagename/src/packagename.php

In that file, it is using a foreach loop to loop over the classes which i have inserted into the config file, so for example, i have a controller in app/Http/Controllers/TestController

// $class in this case equals TestController
foreach ( $allclasses as $class ) {
    $classMethods = [];

    $reflection = new ReflectionClass( $class );
}

When I run the code, i keep getting the following error;

Class TestController does not exist

The original code that i am copying this part from is found here https://github.com/Bulforce/laravel-ext-direct/blob/master/src/Bulforce/ExtDirect/ExtDirect.php at line 133.

I am taking the above code and building it for Laravel 5.6.

My TestController does exist. Im not sure whats going on. Is it trying to look for the controller in the packages/vendor/packagename/src/ directory?

Im really stumpted … Any help would be greatly appreciated.



from Laravel Questions and Answers https://laravelquestions.com/php/laravel-5-6-and-reflection-not-finding-class/
via Lzo Media

No comments:

Post a Comment