Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincej's avatar
Level 15

Laracasts/Flash gives error on L5.1

@JeffreyWay

Almost finished upgrading to 5.1 and am getting an error on Laracasts/Flash:

BadMethodCallException in ServiceProvider.php line 234:
Call to undefined method [package]

which looks ominously similar to the error on the generators package.

I noticed that ALL service providers now have ::class at the end, so tried that without success.

So, is Flash also going the same way as Generators .. ie deprecated ?? Or is there a work around ?

MANY THANKS as always !

0 likes
12 replies
opheliadesign's avatar

@vincej hmm I've been using it just fine in my 5.1 projects. I am using "laracasts/flash": "~1.3",

Can you show some code where this error is being thrown?

coderego's avatar

@vincej Flash works fine for me under 5.1.

Import it with:

'Laracasts\Flash\FlashServiceProvider'

In your config/app.php

You can also use a Alias:

'Flash' => 'Laracasts\Flash\Flash',
1 like
vincej's avatar
Level 15

@opheliadesign @coderego

Thanks guys - Flash worked fine under L5.0 but now that I have upgraded I am getting an error,

I pulled it in through composer with:

 composer require laracasts/flash ~1.3

I see it in my vendor file

I have noticed that all the service providers have ::class at the end, ( I have not seen any thing about this in the upgrade docs ... ) so:

 Laracasts\Flash\FlashServiceProvider::class,

Produces the error:

BadMethodCallException in ServiceProvider.php line 234: Call to undefined method [package]

If I leave the ::class off I get:

Fatal error: Undefined constant 'Laracasts\Flash\FlashServiceProvider' in C:\xampp\htdocs\auburntree\config\app.php >on line 146

If I go to a page where Flash is being used, I get:

BadMethodCallException in ServiceProvider.php line 234: Call to undefined method [package]

Any ideas ??

robgeorgeuk's avatar

Are you running PHP >= 5.5.9? Class name resolution via ::class was introduced in PHP 5.5 and Laravel 5.1 requires PHP >= 5.5.9

vincej's avatar
Level 15

something that might be relevant, but should not be: 99% of the time, I use Linux on my desktop. However, this problem relates to my laptop which has been built with Xampp as a holiday dev environment ... yes I am a sad bastard who takes is work on holiday :o)

1 like
jekinney's avatar

Lol.. If it's relaxing to punch a keyboard it's not really work.

Anyway confirmed it works for me in 5.1 on homestead and PHP sever on w 8.1 and mac osx 10.

I call it with flash(), not Flash::.

vincej's avatar
Level 15

@jekinney

Thanks for that feedback.

It must be me .. it nearly always is me doing something stupid and obvious .... ugh

Yeah .. the ::class thing in the confg.php service providers. I raise it only because in L5.0 Taylor was not using class name resolution in that way, and I have not seen a reference to it's introduction in 5.1

I will delete and start again .. can I just delete flash out of the vendor folder, or is there some special way of deleting a service provider ?

vincej's avatar
Level 15

Well I deleted things and reinstalled ... I got it working ... as I expected it was a dumb ass mistake probably the result of me doing stuff at 1 am rather than sleeping .. or maybe I was sleeping.

Thanks !!

1 like
jekinney's avatar

Lol, we all do it! Glad you got it working!!!

hannylicious's avatar

What did you do to fix it? Just curious - having a similar issue.

Please or to participate in this conversation.