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.
2.x is not compatible is PHP 7. We cannot change the class name String without breaking backwards compatibility.
The class has already been renamed in CakePHP 3.x which is compatible with PHP 7.
You should be using the CakeText class instead of String.
Ah I forgot we did rename the class in 2.x too. But we don't run the testsuite for 2.x on PHP 7 (probably due to phpunit issues) so can't claim compatibility with PHP 7 even though it will probably run.
@ADmad it is also unlikely that all the community plugins have or will switch to CakeText.
Thank you @ADmad & @josegonzalez. I didn't notice it was changed, it worked fine with CakeText now.
@markstory I totally agree with you, but changing it in the Migrations plugin wasn't a bit deal, it's only there in the Console/Command/MigrationShell.php
I know maintaining the compatibility won't always be that easy, but it's worth it, looking into the number of Cake2.x apps and the expected performance enhancements of PHP7.
Thank you all for the efforts
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
@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
@diyfr have your problem resolved ?
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.
@abhilashlohar Yes.
@ADmad sorry for the inconvenience
@josegonzalez thank you for your comment. I have used CakeText insted of String. Now this is working fine. But I am not sure that is right way or not.
CakeText is the right way for Cake 2.x.
@dereuromark thanks
@dereuromark I am getting same error. Can you please hlep me.
I am getting this error in my controller.
{
"code": 500,
"url": "\/2016\/TPO\/project\/orders\/new_order.json",
"name": "Cannot declare class CakeText, because the name is already in use"
}

It must be a dev error on your side. Make sure you only have a single CakeText class (the one CakePHP offers).
@derekperkins CakeText working fine. But while I am fetching data from my MySQL db. This won't work
Most helpful comment
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