在Router.php第366行中:传递给Illuminate \ Routing \ Router :: group()的参数1必须为数组类型,

编程入门 行业动态 更新时间:2024-10-28 17:13:56
本文介绍了在Router.php第366行中:传递给Illuminate \ Routing \ Router :: group()的参数1必须为数组类型,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已将 Laravel 从v5.7更新到了v5.8,现在我的应用程序无法运行.

I have update Laravel from v5.7 to v5.8 and now my application doesn't run.

由于以下问题,我对其进行了更新:提交者需要rebing/graphql-laravel失败

I updated it because of this issue: composer require rebing/graphql-laravel fails

我解决了软件包不兼容的问题,但现在Laravel崩溃了:

I solved the packages incompatibility but now Laravel crashes:

$ php artisan serve In Router.php line 366: Argument 1 passed to Illuminate\Routing\Router::group() must be of the type array, string given, called in /var/www/masvino/Server-bak/vendor/laravel/framework/src/Illuminate/Support/Facades /Facade.php on line 239

我怀疑Laravel的团队改变了这种方法的公司:

I suspect that the Laravel's team changed the firm of this method:

Illuminate \ Routing \ Router.php

/** * Create a route group with shared attributes. * * @param array $attributes * @param \Closure|string $routes * @return void */ public function group(array $attributes, $routes) // line 366 { $this->updateGroupStack($attributes); // Once we have updated the group stack, we'll load the provided routes and // merge in the group's attributes when the routes are created. After we // have created the routes, we will pop the attributes off the stack. $this->loadRoutes($routes); array_pop($this->groupStack); }

这是我的 composer.json 文件的当前内容:

This is the current content of my composer.json file:

{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": [ "framework", "laravel" ], "license": "MIT", "type": "project", "require": { "php": "^7.1.3", "fideloper/proxy": "^4.0", "laravel/framework": "^5.8.0", "laravel/tinker": "^1.0", "mll-lab/laravel-graphql-playground": "^1.1.0", "nuwave/lighthouse": "^4.4.2", "spatie/laravel-cors": "^1.6", "webonyx/graphql-php": "^0.13.8", "rebing/graphql-laravel": "2.1.1" }, "require-dev": { "beyondcode/laravel-dump-server": "^1.0", "filp/whoops": "^2.0", "fzaninotto/faker": "^1.4", "mockery/mockery": "^1.0", "nunomaduro/collision": "^2.0", "phpunit/phpunit": "^7.0" }, "autoload": { "classmap": [ "database/seeds", "database/factories" ], "psr-4": { "App\\": "app/" } }, "autoload-dev": { "psr-4": { "Tests\\": "tests/" } }, "extra": { "laravel": { "dont-discover": [], "providers": [ "Rebing\\GraphQL\\GraphQLServiceProvider" ], "aliases": { "GraphQL": "Rebing\\GraphQL\\Support\\Facades\\GraphQL" } } }, "scripts": { "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" ], "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ] }, "config": { "preferred-install": "dist", "sort-packages": true, "optimize-autoloader": true }, "minimum-stability": "dev", "prefer-stable": true }

我认为问题可能出在此文件中: app/Providers/RouteServiceProvider.php

I think the problem could be in this file: app/Providers/RouteServiceProvider.php

<?php namespace App\Providers; use Illuminate\Support\Facades\Route; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; class RouteServiceProvider extends ServiceProvider { /** * This namespace is applied to your controller routes. * * In addition, it is set as the URL generator's root namespace. * * @var string */ protected $namespace = 'App\Http\Controllers'; /** * Define your route model bindings, pattern filters, etc. * * @return void */ public function boot() { // parent::boot(); } /** * Define the routes for the application. * * @return void */ public function map() { $this->mapApiRoutes(); $this->mapWebRoutes(); // } /** * Define the "web" routes for the application. * * These routes all receive session state, CSRF protection, etc. * * @return void */ protected function mapWebRoutes() { Route::middleware('web') ->namespace($this->namespace) ->group(base_path('routes/web.php')); } /** * Define the "api" routes for the application. * * These routes are typically stateless. * * @return void */ protected function mapApiRoutes() { Route::prefix('api') ->middleware('api') ->namespace($this->namespace) ->group(base_path('routes/api.php')); } }

现在不知道哪种group()方法正确的格式.有人可以帮我解决这个问题吗?预先感谢!

Don't know which is the correct format now for group() method. Can anybody help me figure this out? Thanks in advance!

推荐答案

您可以仅在route/web.php中使用

You can just use in your routes/web.php

Route::group( ['prefix' => 'backend','middleware' => ['auth', 'admin']], function() {}

更多推荐

在Router.php第366行中:传递给Illuminate \ Routing \ Router :: group()的参数1必须为数组类型,

本文发布于:2023-11-25 13:35:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629961.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   参数   类型   php   Router

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!