CakePHP 2 fork that supports PHP 8
Find a file
Diego Surita 0b0ec3ef40 Fix dynamic property creation deprecation warning
There are many classes that create properties dynamically (Controller class for example).
2023-12-19 22:23:26 +01:00
.github/workflows build: Added GitHub Actions workflow to run phpcs. 2023-01-11 22:45:29 +01:00
app docs: Comment on database.php about adding PDO::ATTR_STRINGIFY_FETCHES => true flag in PHP 8.1 2023-02-19 13:58:40 +01:00
docker Docker compose setup to run tests locally. 2023-10-19 23:25:34 +02:00
lib/Cake Fix dynamic property creation deprecation warning 2023-12-19 22:23:26 +01:00
plugins allowing install/cake-wide plugins 2009-08-02 15:01:15 -07:00
vendors we still want the vendors folder - creating empty file to ensure the 2011-03-12 20:11:33 +01:00
.editorconfig Add formatting rules for .yml files to editorconfig. 2014-05-04 18:37:41 +05:30
.gitattributes Adding webfont formats as binary in .gitattributes 2015-01-29 16:38:01 +01:00
.gitignore Update .gitignore 2023-02-03 09:42:19 +01:00
.htaccess Add commented-out Apache pass-through for .well-known directory 2016-04-14 15:10:18 +02:00
.stickler.yml Make stickler ignore 2.x and 2.next branches. 2016-07-01 17:28:50 +05:30
.travis.yml Fix failures on PHP 7.4. Run phpcs on PHP 7.0 2019-12-05 15:11:35 +02:00
build.properties Update build config for new pear server. 2016-11-10 19:41:07 -05:00
build.xml Fix hostname. 2016-11-12 09:41:28 -05:00
composer.json $ composer require --dev phpunit/phpunit:^9.5 2023-01-11 22:45:29 +01:00
CONTRIBUTING.md Update URL in *.md, *.json 2017-03-12 03:04:59 +09:00
docker-compose.yml Docker compose setup to run tests locally. 2023-10-19 23:25:34 +02:00
index.php Use HTTPS for the opensource.org MIT license URL 2017-06-11 00:23:22 +02:00
phpunit.xml.dist feat: Implement a fixture callback class using the PHPUnit TestListener interface. 2023-01-11 22:45:29 +01:00
README.md Allowed dynamic properties in model. 2023-11-13 23:23:07 +01:00
ruleset.xml build: Add exception rule to phpcs to use Type::class in test code. 2023-01-11 22:45:29 +01:00

Fork of CakePHP 2 with support for PHP8

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.

Why I created this fork? 🤔

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.

Why you should NOT use?

  • 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.

When you could use this fork?

Only prerequisite is to have your application already on PHP 7.4. Upgrade project to PHP 8.0 and replace CakePHP with this fork.

Migration

Here are steps I took to migrate my project through all versions to PHP 8.1, maybe it can inspire you:

  1. Decouple your tests from CakeTestCase and other utilities that are coupled to old PHPUnit version.
  2. Once decoupled you can upgrade PHPUnit to the newest version accordingly to your PHP version.
  3. Start upgrading gradually to newer versions of PHP. CakePHP 2 works perfectly fine on 7.0 - 7.4.
  4. Once you're on 7.4 you can switch to 8 and this fork.

Before using 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: https://github.com/kamilwylegala/cakephp2-php8/issues/7 Framework 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.

Installation

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.

Changelog

2023-11-13

  • Silence dynamic property creation warning in Model.php

2023-11-02

  • Fixed: unitialized property in Debugger.php

2023-10-20

  • Fallback to empty string from env() in basics.php and request handler.

2023-10-19

  • Removed usage of deprecated redis->getKeys() in favor of redis->keys().
  • Added docker-compose setup to run tests locally.

2023-09-18

  • Fix for ShellDispatcher where null was passed to strpos function.

2023-08-18

  • Fixed PHP8 deprecation notices. Related mostly to passing null as a $haystack value.

2023-06-02

  • Fixed PHP 8.2 deprecation notices in CakeEvent: Creation of dynamic property ... is deprecated.

2023-02-19

  • Fixed PHP 8.1 MySQL test suite.

2023-02-11

  • Fixed PostgreSQL test suite.

2023-01-30

  • PaginatorHelper fix.

2023-01-22

  • Fixed views cache when relative time is specified.

2023-01-11

  • Fixed test suite to run under PHPUnit 9.5 and PHP8. Big kudos to @tenkoma 👏

2022-10-20

  • MailTransport fix.

2022-10-08

  • Support for full_path when uploading a file, PHP 8.1 only.

2022-09-27

  • Fixed multiple CREATE UNIQUE INDEX statements from schema shell that did not work on PostgreSQL.

2022-03-08

  • Fixed passing params["pass"] argument to invokeArgs when resolving controller action - array_values used to avoid problems with named parameters.

2022-03-03

  • Removed String class.

2022-03-02

  • Fixed ConsoleErrorHandler::handleError to respect error suppression.

2022-01-31

  • Fixed Folder->read, array_values is used to remove keys to prevent usign named arguments in call_user_func_array

2022-01-16

  • Fix Shell ReflectionMethod::__construct default null argument in hasMethod

2022-01-15

  • Readme file update - more explicit content.

2022-01-04

  • Fixed more deprecation notices
    • strtoupper + converting false to array in Mysql.php
    • preg_match where $subject = null in CakeRoute.php
    • strtoupper in DboSource.php
    • Check history for details ☝️

2021-12-20

  • 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

2021-02-24

  • Fixed ErrorHandler accordingly to PHP8 migration guide. Otherwise, error handler is logging too much and doesn't respect configured error_reporting.