Search code examples
phpgoogle-mapssymfonylaravel-5.3laravel-5.4

Script php artisan optimize handling the post-update-cmd event returned with error code 1


General Information

Laravel Version: 5.4
PHP Version: 7.0.15
Operating System and Version: ubuntu 16.04

Issue Description

[I am upgrading from laravel 5.3 to 5.4 ]
In composer.json I have added "toin0u/geocoder-laravel": "^1.0",.I have also removed the config/geocoder.php configuration file . There is no Geocoder alias in the aliases section of the config/app.php.

I have added Geocoder\Laravel\Providers\GeocoderService::class, in config/app.php . but still getting the error when I do composer update or composer install .

```

Nothing to install or update
Package egeloen/http-adapter is abandoned, you should avoid using it. Use >php-http/httplug instead.
Writing lock file Generating autoload files
Illuminate\Foundation\ComposerScripts::postUpdate
php artisan optimize

[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Toin0u\Geocoder\GeocoderServiceProvider' not found

``` My composer.json file looks like

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"minimum-stability": "dev",
"prefer-stable": true,

"require": {
    "php": ">=5.6.4",
    "toin0u/geocoder-laravel": "^1.0",
    //"toin0u/geocoder-laravel": "@stable",
    "laravel/framework": "5.4.*",
    "illuminate/support": "5.4.x",
    "illuminate/console": "5.4.x",
    "symfony/process": "~3.2",
    "barryvdh/laravel-async-queue": "0.6.x",
    "laravelcollective/html": "5.4.x-dev"
},
"require-dev": {
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~5.7",
    "symfony/css-selector": "3.1.*",
    "symfony/dom-crawler": "3.1.*",
    "barryvdh/laravel-debugbar": "^2.1"
},
"autoload": {
    "classmap": [
        "database",
        "app/Models",
        "database/migrations",
        "database/seeds",
        "app/libraries"
    ],
"psr-4": {
        "App\\": "app/"
    }
},

 "extra": {
    "branch-alias": {
        "dev-master": "0.6-dev"
    }
},

"autoload-dev": {
    "classmap": [
        "tests/TestCase.php"
    ]
},
"scripts": {
    "post-root-package-install": [
        "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ],
    "post-install-cmd": [
        "Illuminate\\Foundation\\ComposerScripts::postInstall",
        "php artisan optimize"
    ],
    "post-update-cmd": [
        "Illuminate\\Foundation\\ComposerScripts::postUpdate",
        "php artisan ide-helper:generate", 
        "php artisan ide-helper:meta",
        "php artisan optimize"
    ]
},
"config": {
    "preferred-install": "dist"
}

}

I was using Class 'Toin0u\Geocoder\GeocoderServiceProvider' in my config/app.php file ,thought it could be the problem as it is unable to find this class so I removed this from there still getting the same error message. Please Help . Thank-you in advance !

Edited: My new app.php looks like this:(I have commented the lines involving Geocoder)

<?php

/*code after providers */

'providers' => [

    /*
     * Laravel Framework Service Providers...
     */
    Illuminate\Auth\AuthServiceProvider::class,
    Illuminate\Broadcasting\BroadcastServiceProvider::class,
    Illuminate\Bus\BusServiceProvider::class,
    Illuminate\Cache\CacheServiceProvider::class,
    Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
    Illuminate\Cookie\CookieServiceProvider::class,
    Illuminate\Database\DatabaseServiceProvider::class,
    Illuminate\Encryption\EncryptionServiceProvider::class,
    Illuminate\Filesystem\FilesystemServiceProvider::class,
    Illuminate\Foundation\Providers\FoundationServiceProvider::class,
    Illuminate\Hashing\HashServiceProvider::class,
    Illuminate\Mail\MailServiceProvider::class,
    Illuminate\Notifications\NotificationServiceProvider::class,
    Illuminate\Pagination\PaginationServiceProvider::class,
    Illuminate\Pipeline\PipelineServiceProvider::class,
    Illuminate\Queue\QueueServiceProvider::class,
    Illuminate\Redis\RedisServiceProvider::class,
    Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
    Illuminate\Session\SessionServiceProvider::class,
    Illuminate\Translation\TranslationServiceProvider::class,
    Illuminate\Validation\ValidationServiceProvider::class,
    Illuminate\View\ViewServiceProvider::class,

    /*
     * Package Service Providers...
     */
    Collective\Html\HtmlServiceProvider::class,
    /*registering the Geocoder Service Provider */

    //Geocoder\Laravel\Providers\GeocoderService::class,


    /*
     * Application Service Providers...
     */
    App\Providers\AppServiceProvider::class,
    App\Providers\AuthServiceProvider::class,
    // App\Providers\BroadcastServiceProvider::class,
    App\Providers\EventServiceProvider::class,
    App\Providers\RouteServiceProvider::class,
    // Way\Generators\GeneratorsServiceProvider::class,
    NoHasl\Providers\FormatServiceProvider::class,
    NoHasl\Providers\GeoIPServiceProvider::class,
    //Toin0u\Geocoder\GeocoderServiceProvider::class,
    Barryvdh\Queue\AsyncServiceProvider::class,

],

/*
|--------------------------------------------------------------------------
| Class Aliases
|--------------------------------------------------------------------------
|
| This array of class aliases will be registered when this application
| is started. However, feel free to register as many as you wish as
| the aliases are "lazy" loaded so they don't hinder performance.
|
*/

'aliases' => [

    'App' => Illuminate\Support\Facades\App::class,
    'Artisan' => Illuminate\Support\Facades\Artisan::class,
    'Auth' => Illuminate\Support\Facades\Auth::class,
    'Blade' => Illuminate\Support\Facades\Blade::class,
    'Bus' => Illuminate\Support\Facades\Bus::class,
    'Cache' => Illuminate\Support\Facades\Cache::class,
    'ClassLoader'=> Illuminate\Support\ClassLoader::class,
    'Config' => Illuminate\Support\Facades\Config::class,
    'Cookie' => Illuminate\Support\Facades\Cookie::class,
    'Crypt' => Illuminate\Support\Facades\Crypt::class,
    'DB' => Illuminate\Support\Facades\DB::class,
    'Eloquent' => Illuminate\Database\Eloquent\Model::class,
    'Event' => Illuminate\Support\Facades\Event::class,
    'File' => Illuminate\Support\Facades\File::class,
    'Gate' => Illuminate\Support\Facades\Gate::class,
    'Hash' => Illuminate\Support\Facades\Hash::class,
    'Lang' => Illuminate\Support\Facades\Lang::class,
    'Log' => Illuminate\Support\Facades\Log::class,
    'Mail' => Illuminate\Support\Facades\Mail::class,
    'Notification' => Illuminate\Support\Facades\Notification::class,
    'Password' => Illuminate\Support\Facades\Password::class,
    'Queue' => Illuminate\Support\Facades\Queue::class,
    'Redirect' => Illuminate\Support\Facades\Redirect::class,
    'Redis' => Illuminate\Support\Facades\Redis::class,
    'Request' => Illuminate\Support\Facades\Request::class,
    'Response' => Illuminate\Support\Facades\Response::class,
    'Route' => Illuminate\Support\Facades\Route::class,
    'Schema' => Illuminate\Support\Facades\Schema::class,
    'Session' => Illuminate\Support\Facades\Session::class,
    'Storage' => Illuminate\Support\Facades\Storage::class,
    'URL' => Illuminate\Support\Facades\URL::class,
    'Validator' => Illuminate\Support\Facades\Validator::class,
    'View' => Illuminate\Support\Facades\View::class,
    'Form' => Collective\Html\FormFacade::class,
    'Html' => Collective\Html\HtmlFacade::class,
    'HTML' => Collective\Html\HtmlFacade::class,
    'Format' => NoHasl\Format::class,
    'GeoIP' => NoHasl\GeoIP::class,
    'Input' => Illuminate\Support\Facades\Input::class,

],

];


Solution

  • Remove the lin Geocoder\Laravel\Providers\GeocoderService::class, from the providers list in your app.php config file. Then run composer install or composer update. Once the package is installed you can then go and add the provider back in the app.php config file.

    If you're unable to install the package then remove the line "toin0u/geocoder-laravel": "^1.0", from your composer.json. Then run composer require toin0u/geocoder-laravel to perform a clean install.