cakephp: [2.7] PHP7 Error : 'String' class name is reserved
Today I was testing my CakePHP v2.7.5 application against PHP7 to check on its compatibility and get it ready with the final stable release of php when it arrives.
I got this error when I tried to run some migration files:
Fatal Error Error: Cannot use 'String' as class name as it is reserved in
[.../lib/Cake/Utility/String.php, line 26]
Didn’t test it over with CakePHP v3 but I guess the utility class name “String” should be changed in older versions.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 18 (7 by maintainers)
I was getting same issue. What i did:- I just download the cakephp 2.8 and copy the lib folder from it and replaced to my project.
and Problem Solved
Guys this is not a help forum and your issue is unrelated to this ticket. Please take your discussion to the official forum or stackoverflow.
You should be using the
CakeTextclass instead of String.CakeText is the right way for Cake 2.x.
@diyfr have your problem resolved ?
@ADmad it is also unlikely that all the community plugins have or will switch to CakeText.
@abhilashlohar Yes. @ADmad sorry for the inconvenience
@abhilashlohar I have the same problem and apply your solution, but for static text (i18n) only the first character is displayed. An idea ? Works with 2.3.5 Edit 1: If i deactivate the cache, it’s work !! Edit 2: Resolved. Clear manualy the cache after upgrade CakePhp lib folder
2.x is not compatible is PHP 7. We cannot change the class name
Stringwithout breaking backwards compatibility.The class has already been renamed in CakePHP 3.x which is compatible with PHP 7.