快速解決laravel9提示“Target *classController does not exist”問題!

本篇文章給大家?guī)砹岁P于laravel的相關知識,其中主要給大家介紹在laravel9中提示了target *classcontroller does not exist,該怎么辦?下面一起來看一下解決方案,希望對需要的朋友有所幫助。

快速解決laravel9提示“Target *classController does not exist”問題!

關于 laravel 9 提示 Target *classController does not exist

關于 laravel 9 api 提示 Target class [ApphttpControllersCaptchasController] does not exist 解決方法

1. 打開 appProvidersRouteServiceProvider.php 修改如圖

class?RouteServiceProvider?extends?ServiceProvider { ???. ???. ???. ???. ???. ???protected?$namespace?='AppHttpControllers'; ??public??function?boot() ???{ ?????????$this->configureRateLimiting(); ?????????$this->routes(function?()?{ ????????????Route::middleware('api') ????????????????->prefix('api') ????????????????->namespace($this->namespace) ????????????????->group(base_path('routes/api.php')); ????????????Route::middleware('web') ????????????->namespace($this->namespace) ????????????->group(base_path('routes/web.php')); ????????}); ????} }

2. 打開 appProvidersRouteServiceProvider.php 修改如圖

<?php use IlluminateHttpRequest; use IlluminateSupportFacadesRoute; //use AppHttpControllersApiCaptchasController; Route::prefix(&#39;v1&#39;)     ->name('api.v1.') ????-&gt;namespace("Api")//添加命名空間 ????-&gt;group(function?()?{ ?????????Route::middleware('throttle:'. ?????????config('api.rate_limits.sign')) ????????-&gt;group(function?()?{ ???????????//?Route::post('captchas',?[CaptchasController::class,?'store'])-&gt;name('captchas.store');?---原來的 ??????????????Route::post('captchas',?'CaptchasController@store') ??????????????-&gt;name('captchas.store');//?修改成這樣即可 ?????}); ???????????Route::middleware('throttle:'?.config('api.rate_limits.access')) ????????????-&gt;group(function?()?{ ????????????}); ????})

推薦學習:《laravel視頻教程

以上就是快速解決

? 版權聲明
THE END
喜歡就支持一下吧
點贊14 分享