For original README content please check original repository: https://github.com/cakephp/cakephp/tree/2.x
Unfortunately branch 2.x in original repository was taken down.
CakePHP 2 stopped getting updates in the end of 2019 (AFAIR). Unfortunately in my case it's too expensive to migrate to newer versions of CakePHP. I started migrating to Symfony framework, but I still use ORM from CakePHP (and actually I like it). So in order to keep up with the newest PHP versions I decided to create fork of the framework.
- Intention of this fork is to support PHP 8.*. Fork is not going to receive new features. Instead, fork is going to get minimal set of patches to comply with newer versions of PHP.
- If for example you're still on 5.6 or 7.0, you should not use this fork. Original
cakephp/cakephpworks perfectly fine on all PHP 7.* versions. You should migrate to newer versions of PHP and keep using original code. Once your application is battle tested on production I suggest migrating to PHP 8.
Only prerequisite is to have your application already on PHP 7.4. Upgrade project to PHP 8.0 and replace CakePHP with this fork.
Here are steps I took to migrate my project through all versions to PHP 8.1, maybe it can inspire you:
- Decouple your tests from
CakeTestCaseand other utilities that are coupled to old PHPUnit version. - Once decoupled you can upgrade PHPUnit to the newest version accordingly to your PHP version.
- Start upgrading gradually to newer versions of PHP. CakePHP 2 works perfectly fine on 7.0 - 7.4.
- Once you're on 7.4 you can switch to 8 and this fork.
Tests of CakePHP framework aren't refactored yet to support PHP 8. Main issue is old version of PHPUnit that is tightly coupled to framework's tests. Issue for fixing this situation is here: #7Framework tests are migrated to PHPUnit 9.*. Github actions are running tests on PHP 8.0, 8.1.Due to lack of tests ☝️- you also need to rely on tests in your application after integrating with this fork.- If after integration you spot any issues related to framework please let me know by creating an issue or pull request with fix.
- In order to get rid of
strftime()deprecation notices, it's required to switch toIntlDateFormatterclass. This class is available inintlextension. Fork doesn't require it explicitly but to be able to use its functions Symfony ICU Polyfill is installed. To providestrftimebehavior compatibility,PHP81_BC\strftimeis used.PHP81_BCdoesn't fully cover strftime, your code should work but there is a chance you'll get slightly different results. Discussed (here)[#64] and (here)[#65].
This repository is not available in packagist, therefore your project's composer.json must be changed to point to custom repository.
Example configuration:
{
"require": {
"cakephp/cakephp": "dev-master as 2.10.24",
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/kamilwylegala/cakephp2-php8"
}
]
}
It means that composer will look at master branch of repository configured under repositories to resolve update of cakephp/cakephp package.
- Fixes for PHP 8.4:
session_set_save_handleraccepts object, removedE_STRICTreference. - Removed github action with php code sniffer. It's quite painful to work with. Need to migrate to something newer, that will affect code base as little as possible.
- Inflector fix: str_place with null.
- Added wrapper for PDOException to avoid creating dynamic property
queryString.
- Csrf vulnerabity fix back ported from Cake PHP 3
- Explicit type hint definition of nullable parameters.
- Removed usage of
strftime, replaced with Intl extension.
- Fix deprecation error in Model:
Automatic conversion of false to array is deprecated
- Fix deprecation error in I18n:
Automatic conversion of false to array is deprecated
str_lendeprecation warning fix in CakeResponse (passing null instead ofstring)
strotime()andpreg_split()in CakeResponse deprecation warning fixes (passing null)
preg_replacedeprecation warning fixes (passing null instead ofstring)
preg_quote()passing null fix
- Muted dynamic property creation warnings in Controller.php
- Fix passing a null input to h function (PR #56)
- Fix Hash class callback callable pattern deprecated (PR #58)
- Silence dynamic property creation warning in Model.php
- Fixed: unitialized property in Debugger.php
- Fallback to empty string from
env()in basics.php and request handler.
- Removed usage of deprecated
redis->getKeys()in favor ofredis->keys(). - Added docker-compose setup to run tests locally.
- Fix for
ShellDispatcherwherenullwas passed tostrposfunction.
- Fixed PHP8 deprecation notices. Related mostly to passing null as a
$haystackvalue.
- Fixed PHP 8.2 deprecation notices in CakeEvent:
Creation of dynamic property ... is deprecated.
- Fixed PHP 8.1 MySQL test suite.
- Fixed PostgreSQL test suite.
PaginatorHelperfix.
- Fixed views cache when relative time is specified.
- Fixed test suite to run under PHPUnit 9.5 and PHP8. Big kudos to @tenkoma 👏
MailTransportfix.
- Support for
full_pathwhen uploading a file, PHP 8.1 only.
- Fixed multiple
CREATE UNIQUE INDEXstatements from schema shell that did not work on PostgreSQL.
- Fixed passing
params["pass"]argument toinvokeArgswhen resolving controller action -array_valuesused to avoid problems with named parameters.
- Removed
Stringclass.
- Fixed
ConsoleErrorHandler::handleErrorto respect error suppression.
- Fixed
Folder->read,array_valuesis used to remove keys to prevent usign named arguments incall_user_func_array
- Fix Shell
ReflectionMethod::__constructdefault null argument in hasMethod
- Readme file update - more explicit content.
- Fixed more deprecation notices
strtoupper+converting false to arrayin Mysql.phppreg_matchwhere$subject = nullin CakeRoute.phpstrtoupperin DboSource.php- Check history for details ☝️
- Fixed deprecation notices in PHP 8.1 for production code implementations:
ArrayAccessCountableIteratorAggregate
- PHP 8.0 requirement in composer.json
- Warning: Tests are not updated, Cake's tests rely on old version of PHPUnit so running them may show a lot of deprecations notices. Added issue to cover it: #7
- Fixed ErrorHandler accordingly to PHP8 migration guide. Otherwise, error handler is logging too much and doesn't respect configured
error_reporting.