Prerequisites in Centos VM:
sudo yum -y install glibc-locale-source glibc-langpack-en
sudo localedef -v -c -i es_ES -f UTF-8 es_ES
sudo localedef -v -c -i de_DE -f UTF-8 de_DE
Running tests:
./tests AllTests
To run a single test, you need to use the "Cake namespace" of the class under test. e.g. to run lib/Cake/Model/Datasource/CakeSessionTest
, you would run:
./tests Model/Datasource/CakeSession
By default, the tests run with an sqlite database, to run for MySQL, you need to configure a database connection in app/Config/database.php
and make sure the following empty databases have been created:
cakephp_test
, cakephp_test2
, cakephp_test3
, and then set the env var DB
to mysql
, i.e.:
DB=mysql ./tests AllTests
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/cakephp
works 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
CakeTestCase
and 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: kamilwylegala#7
- Due to lack of tests ☝️ - you 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.
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.
- Fixed passing
params["pass"]
argument toinvokeArgs
when resolving controller action -array_values
used to avoid problems with named parameters.
- Removed
String
class.
- Fixed
ConsoleErrorHandler::handleError
to respect error suppression.
- Fixed
Folder->read
,array_values
is used to remove keys to prevent usign named arguments incall_user_func_array
- Fix Shell
ReflectionMethod::__construct
default null argument in hasMethod
- Readme file update - more explicit content.
- Fixed more deprecation notices
strtoupper
+converting false to array
in Mysql.phppreg_match
where$subject = null
in CakeRoute.phpstrtoupper
in DboSource.php- Check history for details ☝️
- Fixed deprecation notices in PHP 8.1 for production code implementations:
ArrayAccess
Countable
IteratorAggregate
- 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
.