Я пытаюсь организовать свой проект (люмен / laravel) таким образом, чтобы мои элементы управления находились в подпапках, чтобы иметь больше контроля. Я следую официальному руководству по люмену (https://lumen.laravel.com/docs/6.x/controllers), но проблема заключается в следующем:
В моем файле маршрута (маршруты / сеть. php) у меня есть следующий код:
<?php
$router->get('test', 'Photos\TestController@show');
И мой контроллер находится в пути приложения / Http / Controllers / Photos / TestController. php и имеет следующий код:
<?php
namespace App\Http\Controllers;
class TestController extends Controller
{
public function show(){
return "hello";
}
}
Но на момент делая запрос к URL http://localhost/myproject/public/test Я получаю следующее сообщение:
Нажмите, чтобы посмотреть
И в моем файле журнала (хранилище / logs / lumen-xx-xx-xx.log) Я получаю следующую ошибку:
[2020-01-19 02:59:12] local.ERROR: ReflectionException: Class App\Http\Controllers\Photos\TestController does not exist in C:\xampp\htdocs\colegio\vendor\illuminate\container\Container.php:803
Stack trace:
#0 C:\xampp\htdocs\colegio\vendor\illuminate\container\Container.php(803): ReflectionClass->__construct('App\\Http\\Contro...')
#1 C:\xampp\htdocs\colegio\vendor\illuminate\container\Container.php(681): Illuminate\Container\Container->build('App\\Http\\Contro...')
#2 C:\xampp\htdocs\colegio\vendor\illuminate\container\Container.php(629): Illuminate\Container\Container->resolve('App\\Http\\Contro...', Array)
#3 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Application.php(267): Illuminate\Container\Container->make('App\\Http\\Contro...', Array)
#4 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(311): Laravel\Lumen\Application->make('App\\Http\\Contro...')
#5 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(278): Laravel\Lumen\Application->callControllerAction(Array)
#6 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(263): Laravel\Lumen\Application->callActionOnArrayBasedRoute(Array)
#7 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(165): Laravel\Lumen\Application->handleFoundRoute(Array)
#8 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(416): Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(Object(Laravel\Lumen\Http\Request))
#9 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(171): Laravel\Lumen\Application->sendThroughPipeline(Array, Object(Closure))
#10 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(108): Laravel\Lumen\Application->dispatch(NULL)
#11 C:\xampp\htdocs\colegio\public\index.php(28): Laravel\Lumen\Application->run()
#12 {main}
Next Illuminate\Contracts\Container\BindingResolutionException: Target class [App\Http\Controllers\Photos\TestController] does not exist. in C:\xampp\htdocs\colegio\vendor\illuminate\container\Container.php:805
Stack trace:
#0 C:\xampp\htdocs\colegio\vendor\illuminate\container\Container.php(681): Illuminate\Container\Container->build('App\\Http\\Contro...')
#1 C:\xampp\htdocs\colegio\vendor\illuminate\container\Container.php(629): Illuminate\Container\Container->resolve('App\\Http\\Contro...', Array)
#2 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Application.php(267): Illuminate\Container\Container->make('App\\Http\\Contro...', Array)
#3 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(311): Laravel\Lumen\Application->make('App\\Http\\Contro...')
#4 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(278): Laravel\Lumen\Application->callControllerAction(Array)
#5 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(263): Laravel\Lumen\Application->callActionOnArrayBasedRoute(Array)
#6 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(165): Laravel\Lumen\Application->handleFoundRoute(Array)
#7 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(416): Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(Object(Laravel\Lumen\Http\Request))
#8 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(171): Laravel\Lumen\Application->sendThroughPipeline(Array, Object(Closure))
#9 C:\xampp\htdocs\colegio\vendor\laravel\lumen-framework\src\Concerns\RoutesRequests.php(108): Laravel\Lumen\Application->dispatch(NULL)
#10 C:\xampp\htdocs\colegio\public\index.php(28): Laravel\Lumen\Application->run()
#11 {main} {"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Target class [App\\Http\\Controllers\\Photos\\TestController] does not exist. at C:\\xampp\\htdocs\\colegio\\vendor\\illuminate\\container\\Container.php:805)
[stacktrace]
#0 C:\\xampp\\htdocs\\colegio\\vendor\\illuminate\\container\\Container.php(681): Illuminate\\Container\\Container->build('App\\\\Http\\\\Contro...')
#1 C:\\xampp\\htdocs\\colegio\\vendor\\illuminate\\container\\Container.php(629): Illuminate\\Container\\Container->resolve('App\\\\Http\\\\Contro...', Array)
#2 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Application.php(267): Illuminate\\Container\\Container->make('App\\\\Http\\\\Contro...', Array)
#3 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(311): Laravel\\Lumen\\Application->make('App\\\\Http\\\\Contro...')
#4 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(278): Laravel\\Lumen\\Application->callControllerAction(Array)
#5 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(263): Laravel\\Lumen\\Application->callActionOnArrayBasedRoute(Array)
#6 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(165): Laravel\\Lumen\\Application->handleFoundRoute(Array)
#7 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(416): Laravel\\Lumen\\Application->Laravel\\Lumen\\Concerns\\{closure}(Object(Laravel\\Lumen\\Http\\Request))
#8 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(171): Laravel\\Lumen\\Application->sendThroughPipeline(Array, Object(Closure))
#9 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(108): Laravel\\Lumen\\Application->dispatch(NULL)
#10 C:\\xampp\\htdocs\\colegio\\public\\index.php(28): Laravel\\Lumen\\Application->run()
#11 {main}
[previous exception] [object] (ReflectionException(code: -1): Class App\\Http\\Controllers\\Photos\\TestController does not exist at C:\\xampp\\htdocs\\colegio\\vendor\\illuminate\\container\\Container.php:803)
[stacktrace]
#0 C:\\xampp\\htdocs\\colegio\\vendor\\illuminate\\container\\Container.php(803): ReflectionClass->__construct('App\\\\Http\\\\Contro...')
#1 C:\\xampp\\htdocs\\colegio\\vendor\\illuminate\\container\\Container.php(681): Illuminate\\Container\\Container->build('App\\\\Http\\\\Contro...')
#2 C:\\xampp\\htdocs\\colegio\\vendor\\illuminate\\container\\Container.php(629): Illuminate\\Container\\Container->resolve('App\\\\Http\\\\Contro...', Array)
#3 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Application.php(267): Illuminate\\Container\\Container->make('App\\\\Http\\\\Contro...', Array)
#4 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(311): Laravel\\Lumen\\Application->make('App\\\\Http\\\\Contro...')
#5 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(278): Laravel\\Lumen\\Application->callControllerAction(Array)
#6 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(263): Laravel\\Lumen\\Application->callActionOnArrayBasedRoute(Array)
#7 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(165): Laravel\\Lumen\\Application->handleFoundRoute(Array)
#8 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(416): Laravel\\Lumen\\Application->Laravel\\Lumen\\Concerns\\{closure}(Object(Laravel\\Lumen\\Http\\Request))
#9 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(171): Laravel\\Lumen\\Application->sendThroughPipeline(Array, Object(Closure))
#10 C:\\xampp\\htdocs\\colegio\\vendor\\laravel\\lumen-framework\\src\\Concerns\\RoutesRequests.php(108): Laravel\\Lumen\\Application->dispatch(NULL)
#11 C:\\xampp\\htdocs\\colegio\\public\\index.php(28): Laravel\\Lumen\\Application->run()
#12 {main}
"}
Я хотел бы знать, что я делаю неправильно, так как я прочитал документацию несколько раз и все еще могу ' Чтобы найти решение, я также искал inte rnet, и никто не спросил об этом. Заранее большое спасибо.