Skip to content

On Laravel 12, Fatal error after installing php-flasher/flasher-laravel — foreach() argument must be of type array|object, bool given #52 #287

Open

Description

@dlopez525

Immediately after installing php-flasher/flasher-laravel, the application breaks with the following error:

foreach() argument must be of type array|object, bool given
Simply installing the package causes this fatal error.

Steps to Reproduce:

Create a fresh Laravel app.

Run:

composer require php-flasher/flasher-laravel

Load any page in the app — no usage of flasher() or flasher_render() yet.

Laravel crashes with a foreach() error.

Activity

  1. KavanAhmadian commented on Apr 13, 2025

    @KavanAhmadian

    i have this error tooo ..

  2. yoeunes commented on Apr 13, 2025

    @yoeunes
    Member

    Hello @dlopez525 and @KavanAhmadian,

    Thank you for reporting this issue. To help me diagnose and fix this problem efficiently, could you please:

    1. Create a minimal GitHub repository that reproduces this issue with a fresh Laravel installation + PHPFlasher
    2. Include information about your environment:
      • Laravel version
      • PHP version
      • The exact installation command you used

    Thank you

  3. KavanAhmadian commented on Apr 13, 2025

    @KavanAhmadian

    @yoeunes

    php => 8.2
    laravel => 11.3
    commaand => composer require php-flasher/flasher-laravel

    but when i down grade to version 1.15 is worked ..

  4. yoeunes commented on Apr 13, 2025

    @yoeunes
    Member

    @KavanAhmadian Thanks for the version info! Interesting that 1.15 works for you - that's a helpful clue.

    Could you create a quick GitHub repo that shows the issue? Just a basic setup where the error happens would be perfect. This would save me tons of time figuring out exactly what's breaking with Laravel 11.3

  5. dlopez525 commented on Apr 13, 2025

    @dlopez525
    Author

    @yoeunes

    The error I get is when I upgrade from Laravel 11 to 12. Exactly in Laravel version 12.0.6, with PHP 8.3.19

  6. yoeunes commented on Apr 15, 2025

    @yoeunes
    Member

    Hi @dlopez525 and @KavanAhmadian, thanks for the environment details!

    could one of you please create a simple GitHub repository that reproduces the error?

    Seeing it in action is the quickest way for me to diagnose and fix it for both Laravel 11 and 12. Thanks! 🙏

  7. nonoodev commented on Apr 23, 2025

    @nonoodev

    Hi,
    I had the same error.
    I fixed it removing the config/flasher.php file and could check what exactly caused the crash.
    In my case, it was the 'flash_bag' that I just commented and it's now working.
    Has the bug after migrating to laravel 12 and updating all packages.

    The error was in the Flasher \ Prime \ Http \ RequestExtension : 45 in the foreach for aliases.

    foreach ($mapping as $type => $aliases) {
        foreach ($aliases as $alias) {
            $flatMapping[$alias] = $type;
        }
    }

    Don't know if it can help.

    Edit : I had old version of config file, then I just regenerated the config and to completely fix I had to use the command to re publish the css/js in vendor.
    Then just changed the css class .fl-main-container to .fl-wrapper in my code.

    The exact part of config that was breaking the code was :

    'flash_bag' => array(
        'enabled' => true,
         'mapping' => array(
               'success' => array('success'),
               'error' => array('error', 'danger'),
               'warning' => array('warning', 'alarm'),
               'info' => array('info', 'notice', 'alert'),
        ),
    ),

    That should now be :

    'flash_bag' => [
            'success' => ['success'],
            'error' => ['error', 'danger'],
            'warning' => ['warning', 'alarm'],
            'info' => ['info', 'notice', 'alert'],
    ],
  8. abraaoribeiro28 commented on May 16, 2025

    @abraaoribeiro28

    'flash_bag' => [
    'success' => ['success'],
    'error' => ['error', 'danger'],
    'warning' => ['warning', 'alarm'],
    'info' => ['info', 'notice', 'alert'],
    ],

    Thank you for sharing, this worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions