DEV Community

Cover image for Laravel error count(): Parameter must an array or an object that implements Countable
Osman Forhad
Osman Forhad

Posted on • Edited on

Laravel error count(): Parameter must an array or an object that implements Countable

I am working with a project which was developed using Laravel 5.4 and xampp php 5.6 but now my development sever is xampp php 7.2
The problem is that when I am going to run this project it’s displayed me an error which is like below screen shot
Alt Text
So, in that case i am searching solution for this once finally I got the solution. Then I think it’s a php version related error.
So, I decide to place the block of code in the top of the controller file (which controller file the error is generate). the code I got place is like below:
Alt Text
Now I am ready to reload the tab and I see the error is solved.
The block of code I can also place in the top of routes.php file. And this is another method.
So, for solve count(): Parameter must an array error in Laravel. We can put version_compare condition in routes file or controller where we want. And it will solve easily.
.
Happy Coding.
osman forhad
Mobile & Web Application Developer💻

Top comments (0)