Pregunta

I am receiving the following error when using paginate with Eloquent:

Argument 2 passed to Illuminate\Pagination\Factory::__construct() must be an instance of Illuminate\View\Factory, instance of Illuminate\View\Environment given, called in C:\****\vendor\laravel\framework\src\Illuminate\Pagination\PaginationServiceProvider.php on line 23 and defined

For testing purposes, this is all I have in the method of my controller:

return User::paginate(15);

I'm aware about the upgrade procedure from the docs, but I don't have any of the references mentioned there.

Update:

In my specific case there was a package in the workbench which was requiring Illuminate 4.1 components, I changed to 4.2 in composer.json, removed the vendor dir and composer.lock file, did a composer install, and the error is gone.

These operations were all done within the package folder.

¿Fue útil?

Solución

Posted as a comment, but it was the right answer:

Is there any chance you are only requiring some of the Laravel components, and not the entire Laravel framework? If you are only working with some then things like this can get out of whack, especially if not all of your components are updated to 4.2.

Otros consejos

I encountered the same issue as you when I updated from 4.1 to 4.2, which in my case I did a composer update on my development environment before pushing and did a pull from my staging. Now the pagination issue doesn't exist in my development but in my staging, so I figured it might be the issue with git pull missed some files, or cache in the views. So I did remove the entire project and do a clean clone from the repository, that seems to fix the problem.

So not fully sure on how you update, but you might want to check that your updated files has been fully applied.

I also ran into this same problem when upgrading from 4.1 to 4.2, but my fix was different to Phil Sturgeon's.

I simply had to remove the bootstrap/compiled.php file located in the root of the Laravel project.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top