1

Problem

Love L5. But last 24h been a nightmare. None of my 3rd party service providers (SP) are loading. I did a clean install of L5 and tried adding the SPs but still not working.

The SPs install as they should in the vendor folder when running composer update. But when running the L5 I get the error message Class 'LaravelLocalization' not found

composer.json

"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "twbs/bootstrap": "*",
    "intervention/image": "*",
    "laravelcollective/html": "*",
    "barryvdh/laravel-debugbar": "*",
    "davibennun/laravel-push-notification": "dev-laravel5",
    "mcamara/laravel-localization": "1.1.*",
    "tijsverkoyen/css-to-inline-styles": "1.5.5",
    "league/csv": "*"
}, 

app.config

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\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,
    Collective\Html\HtmlServiceProvider::class,

    /*
     * Application Service Providers...
     */
    App\Providers\AppServiceProvider::class,
    App\Providers\AuthServiceProvider::class,
    App\Providers\EventServiceProvider::class,
    App\Providers\RouteServiceProvider::class,

    /*
     * 3rd Party Service Providers...
     */
    Barryvdh\Debugbar\ServiceProvider::class,
    Intervention\Image\ImageServiceProvider::class,
    Davibennun\LaravelPushNotification\LaravelPushNotificationServiceProvider::class,
    Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider::class

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,
    'Cache'     => Illuminate\Support\Facades\Cache::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,
    '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,
    'Debugbar'  => Barryvdh\Debugbar\Facade::class,
    'Image'     => Intervention\Image\Facades\Image::class,
    'PushNotification' => Davibennun\LaravelPushNotification\Facades\PushNotification::class,
    'LaravelLocalization'   => Mcamara\LaravelLocalization\Facades\LaravelLocalization::class

Things I tried

Laravel 5.2 Service provider not booting

php artisan clear-compiled composer dump-autoload php artisan optimize

Laravel - Composer unable to find the service provider class

composer clear

I've also scorched the internet but come up dry.. :( https://laracasts.com/discuss/channels/general-discussion/laravel-5-package-serviceprovider-cant-be-found)

Ideas?

Any ideas how to overcome greatly appreciated. Cannot run the app now and lost a day of work.. :/

UPDATE

The autoload_files.php in vendor/composer does NOT contain some of the frameworks. barryvdh/laravel-debugbar is part of it (does not get loaded) but for instance Mcamara\LaravelLocalization is NOT part of the autoload_files.

But the Mcamara\LaravelLocalization is part of the autoload_static.php under $prefixesPsr0 - if that helps?

autoload_files.php (in /vendor/composer/)

return array(
    '1d1b89d124cc9cb8219922c9d5569199' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest.php',
    '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
    '667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
    'bd9634f2d41831496de0d3dfe4c94881' => $vendorDir . '/symfony/polyfill-php56/bootstrap.php',
    '2c102faa651ef8ea5874edb585946bce' => $vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
    'e7223560d890eab89cda23685e711e2c' => $vendorDir . '/psy/psysh/src/Psy/functions.php',
    '5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
    'f0906e6318348a765ffb6eb24e0d0938' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/helpers.php',
    '58571171fd5812e6e447dce228f52f4d' => $vendorDir . '/laravel/framework/src/Illuminate/Support/helpers.php',
    'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
    'f18cc91337d49233e5754e93f3ed9ec3' => $vendorDir . '/laravelcollective/html/src/helpers.php',
    '4a1f389d6ce373bda9e57857d3b61c84' => $vendorDir . '/barryvdh/laravel-debugbar/src/helpers.php',

);

SOLUTION

A THIRD clean install of L5 where I add in the SPs ONE by ONE seems to work. Just happy to be back on track. Cannot thank everyone enough - big shout out to @MikeBarwick who provided good guidance throughout - THANKS! :)

Community
  • 1
  • 1
Peder Wessel
  • 646
  • 1
  • 9
  • 23
  • A clean install and `composer update`? That definitely isn't a good combination. Composer update merely installs the libraries in your composer.lock file. Did you try running `composer install`? – Rahul Govind Jul 06 '16 at 16:23
  • if You take out LaravelLocalization and keep the other 3, does it work or move to another class? Which one? – Marco Aurélio Deleu Jul 06 '16 at 16:27
  • Are you able to see commands list if you run just `php artisan`? Try with `composer update --no-scripts` in case, then `composer update` again. – phaberest Jul 06 '16 at 16:37
  • RahulGovind: Tried. No joy :/ MarcoAurélioDeleu: Tried. Moves to all other classes (if I only put in one that one fails) phaberest: Will reinstall and see if works – Peder Wessel Jul 06 '16 at 17:10
  • @phaberest php artisan works fine. Composer update also. Gut feeling tells me it is a cache issue. Clean install. Ran `composer install` which requested me to run `composer update`. Did that, packages installs successfully. Added service providers to config. Issue still persists - the SPs do not load :/ – Peder Wessel Jul 06 '16 at 17:26
  • Try deleting `Vendor/Composer` folder and `composer.lock` file AND then run `composer update` – Mike Barwick Jul 06 '16 at 17:50
  • @MikeBarwick Deleting the Vendor/Composer folder leads to the following error when running composer update "Warning: require_once(vendor/composer/autoload_real.php): failed to open stream: No such file or directory" – Peder Wessel Jul 06 '16 at 18:22
  • Hmm, that's odd. `composer update` should regenerate that lock file. Question - you're running composer update from your project root, right? Also - can you post/link your composer.json file? – Mike Barwick Jul 06 '16 at 18:24
  • @MikeBarwick Your right. Was running composer update from www root, not folder root (what happens when you try to cram this in over lunch :)). But deleting the vendor/composer folder stalls composer update from finishing (see above) – Peder Wessel Jul 06 '16 at 18:27
  • Try just removing composer.lock and running composer update (in correct project root) – Mike Barwick Jul 06 '16 at 18:30
  • @MikeBarwick still no joy. Let me update my question with the autload_files in the composer folder - might be helpful – Peder Wessel Jul 06 '16 at 18:43
  • Go through each of the files in vendor/composer folder and remove all code related to the problematic package (that's throwing the error, etc.), then remove composer.lock, and then composer update. – Mike Barwick Jul 06 '16 at 18:47
  • When you installed the package...are you sure you were in the project root? – Mike Barwick Jul 06 '16 at 18:53
  • @MikeBarwick Yes. When I now deleted the information relating to the LaravelLocalization class and run composer update it still does not work. However, if I try to uninstall the package (deleting it from composer.json and running composer update) I now get " I get "Package Mcmara/laravel-localization-1.1.3.0 seems not properly installed". I really appreciate your help btw. Feels awful to be stuck for 30h on this :/ – Peder Wessel Jul 06 '16 at 18:57
  • @MikeBarwick got it to work via a 3rd clean install. Thanks for your help. Much appreciated! – Peder Wessel Jul 06 '16 at 19:53
  • No problem! My guess was, your were running composer installs/commands outside of project. ;) Glad you got it sorted! – Mike Barwick Jul 06 '16 at 20:11
  • If someone else stumbles on the same issue I think the problem was that I copied the composer.json from my existing project over to the newly created L5 installation. When I instead copied the relevant fields within the composer.json and pasted in the newly created and ran composer update things ran smoothly – Peder Wessel Jul 06 '16 at 20:17

2 Answers2

0

Try this:

composer dump-autoload --optimize
Alfredo EM
  • 2,029
  • 1
  • 14
  • 16
0

It's because your are missing class in providers file

$this->app->register(\L5Swagger\L5SwaggerServiceProvider::class);

Paste it under register hope so it will start working.

S.B
  • 13,077
  • 10
  • 22
  • 49