代码之家  ›  专栏  ›  技术社区  ›  Nilay Singh

Laravel升级版本从5.2到5.7

  •  0
  • Nilay Singh  · 技术社区  · 6 年前

    我正在尝试将Laravel应用程序从5.2版本升级到5.7版本,为此我编辑了composer.json文件并添加了以下行:

    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.7.*",
        "doctrine/dbal": "^2.5"
    },
    

    我运行composer update,得到这个错误:

    Script php artisan optimize handling the post-update-cmd event returned with error code 1
    
    My application is throwing errors:
    (1/1) ErrorException
    Declaration of App\Providers\EventServiceProvider::boot(Illuminate\Contracts\Events\Dispatcher $events) should be compatible with Illuminate\Foundation\Support\Providers\EventServiceProvider::boot()
    
    in EventServiceProvider.php line 8
    at HandleExceptions->handleError(2, 'Declaration of App\\Providers\\EventServiceProvider::boot(Illuminate\\Contracts\\Events\\Dispatcher $events) should be compatible with Illuminate\\Foundation\\Support\\Providers\\EventServiceProvider::boot()', '/Applications/MAMP/htdocs/kc/kyo-webservice/app/Providers/EventServiceProvider.php', 8, array('file' => '/Applications/MAMP/htdocs/kc/kyo-webservice/vendor/composer/../../app/Providers/EventServiceProvider.php'))
    in EventServiceProvider.php line 8
    at include('/Applications/MAMP/htdocs/kc/kyo-webservice/app/Providers/EventServiceProvider.php')
    in ClassLoader.php line 444
    at Composer\Autoload\includeFile('/Applications/MAMP/htdocs/kc/kyo-webservice/vendor/composer/../../app/Providers/EventServiceProvider.php')
    in ClassLoader.php line 322
    at ClassLoader->loadClass('App\\Providers\\EventServiceProvider')
    at spl_autoload_call('App\\Providers\\EventServiceProvider')
    in ProviderRepository.php line 208
    at ProviderRepository->createProvider('App\\Providers\\EventServiceProvider')
    in ProviderRepository.php line 144
    at ProviderRepository->compileManifest(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', 'Illuminate\\Notifications\\NexmoChannelServiceProvider', 'Illuminate\\Notifications\\SlackChannelServiceProvider', 'Carbon\\Laravel\\ServiceProvider', 'App\\Providers\\AppServiceProvider', 'App\\Providers\\AuthServiceProvider', 'App\\Providers\\EventServiceProvider', 'App\\Providers\\RouteServiceProvider'))
    in ProviderRepository.php line 61
    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', 'Illuminate\\Notifications\\NexmoChannelServiceProvider', 'Illuminate\\Notifications\\SlackChannelServiceProvider', 'Carbon\\Laravel\\ServiceProvider', 'App\\Providers\\AppServiceProvider', 'App\\Providers\\AuthServiceProvider', 'App\\Providers\\EventServiceProvider', 'App\\Providers\\RouteServiceProvider'))
    in Application.php line 550
    at Application->registerConfiguredProviders()
    in RegisterProviders.php line 17
    at RegisterProviders->bootstrap(object(Application))
    in Application.php line 204
    at Application->bootstrapWith(array('Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables', 'Illuminate\\Foundation\\Bootstrap\\LoadConfiguration', 'Illuminate\\Foundation\\Bootstrap\\HandleExceptions', 'Illuminate\\Foundation\\Bootstrap\\RegisterFacades', 'Illuminate\\Foundation\\Bootstrap\\RegisterProviders', 'Illuminate\\Foundation\\Bootstrap\\BootProviders'))
    in Kernel.php line 162
    at Kernel->bootstrap()
    in Kernel.php line 146
    at Kernel->sendRequestThroughRouter(object(Request))
    in Kernel.php line 116
    at Kernel->handle(object(Request))
    in index.php line 53
    

    升级Laravel应用程序的过程是什么,在我的情况下,我应该怎么做?

    1 回复  |  直到 6 年前
        1
  •  1
  •   SystemGlitch    6 年前

    您可以在Laravel文档中找到升级指南。您需要一次升级一个版本:

    此外,在升级之前,您可能应该清除缓存:

    1. 删除中的所有内容 /bootstrap/cache/files
    2. 清除缓存 php artisan cache:clear
    3. 清除视图缓存以防万一 php artisan view:clear