Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel注释扫描路径不为';行不通_Php_Laravel_Laravelcollective - Fatal编程技术网

Php Laravel注释扫描路径不为';行不通

Php Laravel注释扫描路径不为';行不通,php,laravel,laravelcollective,Php,Laravel,Laravelcollective,最近,我正在使用它,并试图在我们的项目中使用它。在实现包扫描路由后,不要扫描控制器中定义的路由 安装软件包: "laravelcollective/annotations": "^8.0.1", 在将包实现到我们的应用程序中并尝试使用以下命令后: php artisan route:scan 此文件在存储/框架/模型中为空。已扫描和存储/框架/路由。已扫描 这是我注册到app.conf文件中的AnnotationsServiceProvider类内容

最近,我正在使用它,并试图在我们的项目中使用它。在实现包扫描路由后,不要扫描控制器中定义的路由

安装软件包:

"laravelcollective/annotations": "^8.0.1",
在将包实现到我们的应用程序中并尝试使用以下命令后:

php artisan route:scan
此文件在
存储/框架/模型中为空。已扫描
存储/框架/路由。已扫描

这是我注册到app.conf文件中的
AnnotationsServiceProvider
类内容

App\Providers\AnnotationsServiceProvider::class,
AnnotationsServiceProvider.php
content:

检查是否在AnnotationsServiceProvider类中扩展了“Collective\Annotations\AnnotationsServiceProvider”。如果生成了要扩展的类,则默认情况下为“illumb\Support\ServiceProvider”

如果您在类中获得了自动生成的方法“boot”和“register”,请删除它们或确保在em中调用父方法“boot”和“register”

对于“app.conf”,我希望您参考laravel项目中的config/app.php文件

namespace App\Providers;

use Collective\Annotations\AnnotationsServiceProvider as ServiceProvider;

class AnnotationsServiceProvider extends ServiceProvider
{

    /**
     * The classes to scan for event annotations.
     *
     * @var array
     */
    protected $scanEvents = [];

    /**
     * The classes to scan for route annotations.
     *
     * @var array
     */
    protected $scanRoutes = [
        \App\Http\Controllers\AdminController::class
    ];

    /**
     * The classes to scan for model annotations.
     *
     * @var array
     */
    protected $scanModels = [
        \App\User::class,
    ];

    /**
     * Determines if we will auto-scan in the local environment.
     *
     * @var bool
     */
    protected $scanWhenLocal = true;

    /**
     * Determines whether or not to automatically scan the controllers
     * directory (App\Http\Controllers) for routes
     *
     * @var bool
     */
    protected $scanControllers = true;

    /**
     * Determines whether or not to automatically scan all namespaced
     * classes for event, route, and model annotations.
     *
     * @var bool
     */
    protected $scanEverything = false;



    /**
     * Register services.
     *
     * @return void
     */
    public function register()
    {
        //
        parent::register();
    }

    /**
     * Bootstrap services.
     *
     * @return void
     */
    public function boot()
    {
        //
        parent::boot();
    }


}
这将使“phpartisanroute:scan”命令起作用

$ php artisan route:scan
Routes scanned!
要使路线正常工作,您需要在注释注释中添加一个额外的*

/**
 * Show the Index Page
 * @Get("/posts/search")
 */

@John在评论部分添加额外的*解决了我的问题problem@DolDurma是的,我试过了,发现这个问题。在回答中添加了这一点,即使问题是关于如何使扫描仪工作。我怎样才能问你另一个问题?当我将
@Resource
添加到任何只使用
参数创建多个路由的
控制器的顶部时,我确切地支持用php编写代码,而不是在注释中:)资源是一个CRUD实体,所以我猜注释可以在一个注释中提供所有这些路由(创建、读取、更新、删除)(还有索引)是的,没错,你知道我们如何将它们结合起来吗?