Framework: This mornings update to 5.5.16 breaks our Lumen site

Created on 16 Oct 2017  路  14Comments  路  Source: laravel/framework

Good morning,

  • Laravel Version: Lumen (5.5.1) (Laravel Components 5.5.*)
  • PHP Version: 7.1
  • Database Driver & Version:

Description:

Receiving this issue from our Lumen site after this AMs update to 5.5.16. I think it is due to having no views defined.
at Application->Laravel\Lumen\Concerns{closure}(2, 'Invalid argument supplied for foreach()', '/var/www/bmc-api/vendor/illuminate/support/ServiceProvider.php', 84, array('path' => '/var/www/bmc-api/vendor/illuminate/pagination/resources/views', 'namespace' => 'pagination'))
in ServiceProvider.php (line 84)

protected function loadViewsFrom($path, $namespace)
{
    foreach ($this->app->config['view']['paths'] as $viewPath) {
        if (is_dir($appPath = $viewPath.'/vendor/'.$namespace)) {
            $this->app['view']->addNamespace($namespace, $appPath);
        }
    }

    $this->app['view']->addNamespace($namespace, $path);
}

I commented out the code of the function to get back online.

Steps To Reproduce:

Composer update and run.

Most helpful comment

In order to reproduce this on a default Lumen installation you must enable eloquent so that the Application actually tries to load the PaginationServiceProvider. This ultimately causes the error because the loadViewsFrom method changed in 5.5.15 (in this commit) from

protected function loadViewsFrom($path, $namespace)
{
    if (is_dir($appPath = $this->app->resourcePath().'/views/vendor/'.$namespace)) {
        $this->app['view']->addNamespace($namespace, $appPath);
    }
    $this->app['view']->addNamespace($namespace, $path);
}

to

protected function loadViewsFrom($path, $namespace)
{
    foreach ($this->app->config['view']['paths'] as $viewPath) {
        if (is_dir($appPath = $viewPath.'/vendor/'.$namespace)) {
            $this->app['view']->addNamespace($namespace, $appPath);
        }
    }

    $this->app['view']->addNamespace($namespace, $path);
}

Until a patch is released you can add a 'view.php' configuration file, define paths as an empty array, and configure it before making the call to enable eloquent.

<?php
return [
    'paths' => []
];

All 14 comments

Can't replicate this in a fresh lumen installation, can you please share more information on the issue?

Thanks for the update. I had to roll back. I will try to reproduce again tomorrow with a fresh install.

Got the same error after run composer update.

In order to reproduce this on a default Lumen installation you must enable eloquent so that the Application actually tries to load the PaginationServiceProvider. This ultimately causes the error because the loadViewsFrom method changed in 5.5.15 (in this commit) from

protected function loadViewsFrom($path, $namespace)
{
    if (is_dir($appPath = $this->app->resourcePath().'/views/vendor/'.$namespace)) {
        $this->app['view']->addNamespace($namespace, $appPath);
    }
    $this->app['view']->addNamespace($namespace, $path);
}

to

protected function loadViewsFrom($path, $namespace)
{
    foreach ($this->app->config['view']['paths'] as $viewPath) {
        if (is_dir($appPath = $viewPath.'/vendor/'.$namespace)) {
            $this->app['view']->addNamespace($namespace, $appPath);
        }
    }

    $this->app['view']->addNamespace($namespace, $path);
}

Until a patch is released you can add a 'view.php' configuration file, define paths as an empty array, and configure it before making the call to enable eloquent.

<?php
return [
    'paths' => []
];

I am also seeing this on a clean lumen install but without any modifications besides copy .env.example to .env.

same error.

same error in lumen.

@adalytic-cj your solution works. but also i added $app->configure('view'); to bootstrap/app.php before $app->withEloquent();

I got the same issue on fresh lumen install

Add this file to your config folder to fix the issue: view.php and add

$app->configure('view');

to bootstrap/app.php

Same here.
After running composer update on my 3 microservices, got error

screen shot 2017-10-17 at 13 21 09

Update:

After adding $app->configure('view'); to app.php problem looks fixed.

Still, this is a breaking change and bug, should be fixed on lumen side.

I hav the same error, when trying to open a fresh Lumen installation; and after updating composer.
I am new to Lumen, but I cant find any config folder.

@ykocaman
Putting this without having view configuration file also works, so essentialy you only need to put this two line
$app->configure('view');
$app->withEloquent();

Was this page helpful?
0 / 5 - 0 ratings