Back to API Generator Support

Error:count(): Parameter must be an array or an object that implements Countable

Post a reply
1746 views
parth32067
parth32067

I m getting this error
https://imgur.com/a/MOhxa8S
while consuming api which i created on october cms with php 7.2.
I guess it's because of count's behavior change is done in php 7.2 onwards .Is there any workaround?
Any help will be appricated.

Thanks in advance

demrich32641
demrich32641

Was there any work around found for this? I ran into the same issue

parth32067
parth32067

demrich32641 said:

Was there any work around found for this? I ran into the same issue

Nope. Instead, I used built-in Rest API provided by October CMS. I have created Routes.php in models then included model I want to use then returned modelname::All() as response for given api url

demrich32641
demrich32641

parth32067 said:

demrich32641 said:

Was there any work around found for this? I ran into the same issue

Nope. Instead, I used built-in Rest API provided by October CMS. I have created Routes.php in models then included model I want to use then returned modelname::All() as response for given api url

Ahh, ok. That might be the better route. I found the fix for this, you simply change any instance of count() to !isempty() in the api controllers and helpers. Author might want to update, as its deprecated.

1-5 of 5

Reply to this discussion

You cannot edit posts or make replies: You should be logged in before you can post.