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

本篇文章给大家带来了关于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 分享