快速解决laravel9提示“Target *classController does not exist”问题!
2994
本篇文章给大家带来了关于Laravel的相关知识,其中主要给大家介绍在Laravel9中提示了Target *classController does not exist,该怎么办?下面一起来看一下解决方案,希望对需要的朋友有所帮助。
关于 laravel 9 提示 Target *classController does not exist
关于 laravel 9 api 提示 Target class [App\\Http\\Controllers\\CaptchasController] does not exist 解决方法
1、打开 app\Providers\RouteServiceProvider.php 修改如图
- class RouteServiceProvider extends ServiceProvider
- {
- .
- .
- .
- .
- .
- protected $namespace ='App\\Http\\Controllers';
- 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、打开 app\Providers\RouteServiceProvider.php 修改如图
- <?php
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Route;
- //use App\Http\Controllers\Api\CaptchasController;
- Route::prefix('v1')
- ->name('api.v1.')
- ->namespace("Api")//添加命名空间
- ->group(function () {
- Route::middleware('throttle:'.
- config('api.rate_limits.sign'))
- ->group(function () {
- // Route::post('captchas', [CaptchasController::class, 'store'])->name('captchas.store'); ---原来的
- Route::post('captchas', 'CaptchasController@store')
- ->name('captchas.store');// 修改成这样即可
- });
- Route::middleware('throttle:' .config('api.rate_limits.access'))
- ->group(function () {
- });
- })
本文网址:https://www.zztuku.com/detail-13715.html
站长图库 - 快速解决laravel9提示“Target *classController does not exist”问题!
申明:本文转载于《learnku》,如有侵犯,请 联系我们 删除。
您还没有登录,请 登录 后发表评论!
提示:请勿发布广告垃圾评论,否则封号处理!!