theGreenCabbage theGreenCabbage - 7 months ago 48
PHP Question

PHP Fatal error: Class 'Vinkla\Hashids\HashidsServiceProvider' not found

I was developing on my dev machine using Homestead. I committed both my

composer.lock
and
composer.json
. During this branch, I added
Hashid
and
LaravelDebugBar
to composer for development purposes. Everything worked fine on the development machine.

Once I pulled from master to my production machine, and ran
composer update
, and I get the following error:

enter image description here

When I type in
php artisan migrate
or
composer update
, I get the following error:

PHP Fatal error: Class 'Vinkla\Hashids\HashidsServiceProvider' not found in /var/www/schedulizer/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146


[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Vinkla\Hashids\HashidsServiceProvider' not found


I tried
composer clear-compiled
,
composer dump-autoload
tried manually requiring the
Hashid
package, and removing the offending lines in
config/app.php
and running composer update

I checked the service provider, and it is in my
config/app.php
..

Answer

Instead of running composer update, run composer install on the production machine instead; this will bypass the pre-update hooks that Laravel runs.

Source

If they were dev requirements, then you can conditionally add them to your service providers list by adding them to your AppServiceProvider like such:

// AppServiceProvider.php

public function register()
{
    /* ... */

    if ($this->app->environment('production')) {
        // $this->app->register('');
    } else {
        $this->app->register('Vinkla\Hashids\HashidsServiceProvider');
    }
}

Source

Comments