Cannot use Crud\Core\Objec

1

I was not using the API for long time and then we switched to PHP 7.2. It shows the error below. OS is Ubuntu 14.04.6 .

I am a beginner and have no idea where to start from. I'd be thankful if someone could tell me where to start from.

composer.json looks like this:

"require": {
    "php": ">=5.5.9", 
    "cakephp/cakephp": "~3.2",
    "mobiledetect/mobiledetectlib": "2.*",
    "cakephp/migrations": "~1.0",
    "cakephp/plugin-installer": "*",
    "friendsofcake/crud":"~4.0"

Fatal error: Cannot use Crud\Core\Object as Object because 'Object' is a special class name in /www/htdocs/w0555555e/api.website.com/vendor/friendsofcake/crud/src/Listener/BaseListener.php on line 4

user2917597

Posted 2019-06-12T14:35:04.913

Reputation: 11

Answers

0

FriendsOfCake 4.0 doesn't support PHP 7.2. Since Object has become a keyword in PHP 7.2, FriendsOfCake can't use it as a class name anymore.

This was fixed in a later version of FriendsOfCake as referenced in this pull request on GitHub.

Try updating to version 5.2.0 or later by updating the line:

    "friendsofcake/crud":"~4.0"

to:

    "friendsofcake/crud":"~5.2.0"

and then running:

composer update

You may need to update some other dependencies as well.

Worthwelle

Posted 2019-06-12T14:35:04.913

Reputation: 3 556

Thanks.I followed what described in the pull request. now error is : "Warning (2): count() [<a href='php.net/function.count'>function.count</a>]: Parameter must be an array or an object that implements Countable [CORE/src/Database/QueryCompiler.php, line 128]" Do you mean i need to change the text on line 2 of composer.json in vendor/friendsofcake/crud from "name":"friendsofcake/crud" > "name":"friendsofcake/crud":"~5.2.0"
I also acessed via SSH and opened the api directory and ran composer update and here is the response bash: composer: command not found
– user2917597 – 2019-06-13T07:12:28.713

You don't need to manually apply the changes in the pull request. Just install composer on the system and run composer update after changing line 7 in composet.json. – Worthwelle – 2019-06-13T13:07:25.487