快速解决laravel9提示“Target *classController does not exist”问题!

 2994

本篇文章给大家带来了关于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 [App\\Http\\Controllers\\CaptchasController] does not exist 解决方法

1、打开 app\Providers\RouteServiceProvider.php 修改如图

  1. class RouteServiceProvider extends ServiceProvider
  2. {
  3.    .
  4.    .
  5.    .
  6.    .
  7.    .
  8.    protected $namespace ='App\\Http\\Controllers';
  9.   public  function boot()
  10.    {
  11.          $this->configureRateLimiting();
  12.          $this->routes(function () {
  13.             Route::middleware('api')
  14.                 ->prefix('api')
  15.                 ->namespace($this->namespace)
  16.                 ->group(base_path('routes/api.php'));
  17.             Route::middleware('web')
  18.             ->namespace($this->namespace)
  19.             ->group(base_path('routes/web.php'));
  20.         });
  21.     }
  22. }

2、打开 app\Providers\RouteServiceProvider.php 修改如图

  1. <?php
  2. use Illuminate\Http\Request;
  3. use Illuminate\Support\Facades\Route;
  4. //use App\Http\Controllers\Api\CaptchasController;
  5. Route::prefix('v1')
  6.     ->name('api.v1.')
  7.     ->namespace("Api")//添加命名空间
  8.     ->group(function () {
  9.          Route::middleware('throttle:'.
  10.          config('api.rate_limits.sign'))
  11.         ->group(function () {
  12.             // Route::post('captchas', [CaptchasController::class, 'store'])->name('captchas.store'); ---原来的
  13.             Route::post('captchas', 'CaptchasController@store')
  14.             ->name('captchas.store');// 修改成这样即可
  15.          });
  16.         Route::middleware('throttle:' .config('api.rate_limits.access'))
  17.                 ->group(function () {
  18.             });
  19.     })


TAG标签:
本文网址:https://www.zztuku.com/detail-13715.html
站长图库 - 快速解决laravel9提示“Target *classController does not exist”问题!
申明:本文转载于《learnku》,如有侵犯,请 联系我们 删除。

评论(0)条

您还没有登录,请 登录 后发表评论!

提示:请勿发布广告垃圾评论,否则封号处理!!

    编辑推荐

    社交网站内容对SEO的价值