我使用composer升级到Laravel 5.3,这打破了它

2024-03-08

这是我尝试运行页面时遇到的异常。我尝试根据我在网上看到的一些建议删除并重新创建引导程序/缓存。我尝试删除 ServiceProvider 文件中启动方法的参数。什么都不起作用。

ErrorException in EventServiceProvider.php line 9:
Declaration of App\Providers\EventServiceProvider::boot() should be compatible with Illuminate\Foundation\Support\Providers\EventServiceProvider::boot()
in EventServiceProvider.php line 9
at HandleExceptions->handleError('2048', 'Declaration of App\Providers\EventServiceProvider::boot() should be compatible with Illuminate\Foundation\Support\Providers\EventServiceProvider::boot()', 'C:\xampp\htdocs\laravel\app\Providers\EventServiceProvider.php', '9', array('file' => 'C:\xampp\htdocs\laravel\vendor\composer/../../app\Providers\EventServiceProvider.php')) in EventServiceProvider.php line 9
at include('C:\xampp\htdocs\laravel\app\Providers\EventServiceProvider.php') in ClassLoader.php line 414
at Composer\Autoload\includeFile('C:\xampp\htdocs\laravel\vendor\composer/../../app\Providers\EventServiceProvider.php') in ClassLoader.php line 301
at ClassLoader->loadClass('App\Providers\EventServiceProvider')
at spl_autoload_call('App\Providers\EventServiceProvider') in ProviderRepository.php line 146
at ProviderRepository->createProvider('App\Providers\EventServiceProvider') in ProviderRepository.php line 74
at ProviderRepository->load(array('Illuminate\Auth\AuthServiceProvider', 'Illuminate\Broadcasting\BroadcastServiceProvider', 'Illuminate\Bus\BusServiceProvider', 'Illuminate\Cache\CacheServiceProvider', 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 'Illuminate\Cookie\CookieServiceProvider', 'Illuminate\Database\DatabaseServiceProvider', 'Illuminate\Encryption\EncryptionServiceProvider', 'Illuminate\Filesystem\FilesystemServiceProvider', 'Illuminate\Foundation\Providers\FoundationServiceProvider', 'Illuminate\Hashing\HashServiceProvider', 'Illuminate\Mail\MailServiceProvider', 'Illuminate\Pagination\PaginationServiceProvider', 'Illuminate\Pipeline\PipelineServiceProvider', 'Illuminate\Queue\QueueServiceProvider', 'Illuminate\Redis\RedisServiceProvider', 'Illuminate\Auth\Passwords\PasswordResetServiceProvider', 'Illuminate\Session\SessionServiceProvider', 'Illuminate\Translation\TranslationServiceProvider', 'Illuminate\Validation\ValidationServiceProvider', 'Illuminate\View\ViewServiceProvider', 'Collective\Html\HtmlServiceProvider', 'App\Providers\AppServiceProvider', 'App\Providers\AuthServiceProvider', 'App\Providers\EventServiceProvider', 'App\Providers\RouteServiceProvider')) in Application.php line 540
at Application->registerConfiguredProviders() in RegisterProviders.php line 17
at RegisterProviders->bootstrap(object(Application)) in Application.php line 203
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 254
at Kernel->bootstrap() in Kernel.php line 145
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 54

另外,当我运行“composer update”时,出现以下异常:

事件服务提供者.php

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        'App\Events\SomeEvent' => [
            'App\Listeners\EventListener',
        ],
    ];

    /**
     * Register any other events for your application.
     *

     * @return void
     */
    public function boot()
    {
        parent::boot();

        //
    }
}

路由服务提供商.php

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Routing\Router;
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.
     *
     * @param  \Illuminate\Routing\Router  $router
     * @return void
     */
    public function map(Router $router)
    {
        $this->mapWebRoutes($router);

        //
    }

    /**
     * Define the "web" routes for the application.
     *
     * These routes all receive session state, CSRF protection, etc.
     *
     * @param  \Illuminate\Routing\Router  $router
     * @return void
     */
    protected function mapWebRoutes(Router $router)
    {
        $router->group([
            'namespace' => $this->namespace, 'middleware' => 'web',
        ], function ($router) {
            require app_path('Http/routes.php');
        });
    }
}

AuthServiceProvider.php

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        'App\Model' => 'App\Policies\ModelPolicy',
    ];

    /**
     * Register any application authentication / authorization services.
     *

     * @return void
     */
    public function boot()
    {
        $this->registerPolicies();

        //
    }
}

您需要从中删除参数RouteServiceProvider and EventServiceProvider.

来自升级指南 https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0:

您可以从 EventServiceProvider、RouteServiceProvider 和 AuthServiceProvider 类的 boot 方法中删除参数。对给定参数的任何调用都可以转换为使用等效的外观。因此,例如,您可以简单地调用事件外观,而不是调用 $dispatcher 参数上的方法。同样,您可以调用 Route 外观,而不是对 $router 参数进行方法调用,并且您可以调用 Gate 外观,而不是对 $gate 参数进行方法调用。

拉拉维尔 5.2EventServiceProvider例子:

namespace App\Providers;

use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        'App\Events\SomeEvent' => [
            'App\Listeners\EventListener',
        ],
    ];

    /**
     * Register any other events for your application.
     *
     * @param  \Illuminate\Contracts\Events\Dispatcher  $events
     * @return void
     */
    public function boot(DispatcherContract $events)
    {
        parent::boot($events);

        //
    }
}

拉拉维尔 5.3EventServiceProvider例子:

namespace App\Providers;

use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        'App\Events\SomeEvent' => [
            'App\Listeners\EventListener',
        ],
    ];

    /**
     * Register any events for your application.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();

        //
    }
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

我使用composer升级到Laravel 5.3,这打破了它 的相关文章

  • 如何在 F# 中捕获任何异常(System.Exception)而不发出警告?

    我试图捕获异常 但编译器给出警告 此类型测试或向下转型将始终保持 let testFail try printfn Ready for failing failwith Fails with System ArgumentException
  • 如何从 obj-c / ios 中的堆栈跟踪获取源代码行

    I use NSSetUncaughtExceptionHandler将堆栈跟踪打印到 iPhone 中的本地文件 该文件将在下次应用程序启动时发送到我们的服务器 然后我可以检查异常数据并修复错误 在某些崩溃中 我有模块名称和引发异常的函数
  • 启用 Chrome Headless 时 Dusk 测试失败

    我有一个 HTML 元素 该元素应该仅在第一页加载时显示 Javascript 设置 cookie 如果设置了 cookie 则不会显示该元素 PHP 检查 cookie 如果 cookie 存在 则不会呈现内容 我正在尝试为此进行 lar
  • 如何在控制器中获取 User()->id (Laravel 8+)

    我正在尝试通过以下方式选择任务用户身份 但我无法将其放入控制器 我从中选择数据DB 我尝试过很多事情 其中 一些来自堆栈溢出 但它不起作用 I tried 1 userId Auth check Auth id true 2 Auth us
  • 如何在 Laravel 中返​​回唯一值

    这里我有这个示例数据 它根据类别产品返回 我需要限制重复值 Raw JSON brand id fe877b45 8620 453a 8805 63f0cbd80752 name No Brand slug no brand descrip
  • 最佳实践:从属性中抛出异常

    什么时候适合从属性 getter 或 setter 中抛出异常 什么时候不合适呢 为什么 关于这个主题的外部文档的链接会很有帮助 谷歌搜索结果出奇的少 Microsoft 在以下位置提供了有关如何设计属性的建议 http msdn micr
  • AngularJS + Laravel 5 身份验证

    在使用 AngularJS 构建 SPA 时 我想在 AngularJS 网站中实现用户身份验证 但是 我不知道从哪里开始以及最佳实践是什么 基本上我有一个确定可以担任一个或多个角色 我寻找了一些例子 这样我就可以对如何正确处理这个问题有一
  • 我们什么时候应该在方法中抛出异常或捕获异常?

    我一直在阅读有关异常的更多内容 但我不确定在什么情况下我们应该抛出一个方法 public void fxml throws IOException method body here 或捕获方法内的异常 public void fxml FX
  • Gson.toString() 给出错误“IllegalArgumentException:多个名为 mPaint 的 JSON 字段”

    我想将自定义对象转换为字符串并保存在 SharedPreferences 中 这是我的最终目标 我尝试了下面的行但失败了 String matchString gson toJson userMatches Logcat 10 11 15
  • 使用 with 的热切加载模型,但给它起了另一个名字 - Laravel 5.2

    是否可以使用 with 方法来使用预加载 但给它另一个名称 就像是 gt with documents as product documents documents as categories 我有一个可以是产品或类别的文档表 急切加载可以
  • Laravel 雄辩的 withCount() 应该比 with() 慢

    所以我问这个的原因是在我当前的应用程序中withCount 与仅通过以下方式获取关系的所有数据相比 响应时间几乎增加了三倍with 并只是从前端获取长度 javascript 我认为使用的要点withCount 是为了加快查询速度 但也许我
  • 有没有办法在 Windows 上全局安装 Composer?

    我读过全局安装文档 http getcomposer org doc 00 intro md globally对于 Composer 但仅适用于 nix 系统 curl s https getcomposer org installer p
  • 在 Laravel 5.4 中选择下拉列表的选定值

    我有一个名为 名称 的下拉列表 用户将在其中选择其中一个 提交后 如果出现一些错误 那么我想选择所选的名称 我在 laravel 5 4 中使用它 控制器 info DB table designation gt where status
  • 如何在 C# 中捕获等待的异步方法的异常?

    我基本上想知道在 C 中我应该如何捕获通过等待的异步方法的异常await关键词 例如 考虑以下小控制台程序 其中最重要的是包含一个名为AwaitSync AwaitSync calls TestAsync 它返回一个任务 执行时会抛出异常
  • 仅针对某些异常类型中断

    我知道异常处理是一件非常重要的事情 我们在所有项目中都在这样做 主要原因是记录客户发生的错误 这工作正常 根本不是问题 但是 当我仍在使用 Visual Studio 编码和运行应用程序时 我根本不需要任何异常处理 我希望调试器正好停在应用
  • 哎呀,看起来像出事了。拉拉维尔 5.1

    我有这样的路线 http localhost inspection show id 当我尝试同时加载路线时 在不同的选项卡中 有时其中一些选项卡会出现错误 哎呀 看起来出了问题 在不同选项卡中加载速度如此之快 http localhost
  • Android ListView addHeaderView() XML 中定义的预定义视图出现 nullPointerException

    尝试使用addHeaderView and addFooterView for a ListView 如果我尝试使用在 XML 中为页眉或页脚预定义的视图 则会出现空指针异常 但是 如果我使用代码动态创建一个视图 它工作得很好 This d
  • 如何将exe异常路由回VB6应用程序?

    我有一个 vb6 应用程序 它将调用 mencoder exe 它是 mplayer 的一部分 用于将某些文件转换为 flv 格式 每当我尝试转换这个 opendivx 文件时 我都会从 mencoder 收到这个奇怪的未处理异常问题 目前
  • 捕获 SQLAlchemy 异常

    我可以使用什么捕获 SQLAlechmy 异常的上层异常 gt gt gt from sqlalchemy import exc gt gt gt dir exc ArgumentError CircularDependencyError
  • 我可以在 Laravel 5.2 中创建一个继承自 User 的新类吗?

    我对 Laravel 还很陌生 使用的是迄今为止的最新版本 5 2 因此我遇到了以下困境 我知道 Laravel 附带了一个User开箱即用的类 但我想开发一个系统 在其中我可以有另外两种类型的用户 称为Researcher and Adm

随机推荐