dereuromark/cakephp-shim

A CakePHP plugin to shim applications between major framework versions.

Installs: 769 510

Dependents: 7

Suggesters: 0

Security: 0

Stars: 37

Watchers: 4

Forks: 11

Open Issues: 0

Type:cakephp-plugin


README

CI Coverage Latest Stable Version Minimum PHP Version License Total Downloads Coding Standards

Shim plugin to "shim" functionality up and down for CakePHP major versions. It also provides some small app-specific fixes.

This branch is for shimming 4.x in 5.x

It provides compatibility wrapper access to 4.x functionality in 5.x.

This is mainly useful when upgrading large applications to the next major framework version. Tons of code needs to be adjusted, using this Shim plugin quite a few lines less need to be touched. Especially the ORM layer, which would need heavy refactoring, requires a lot less changes to get things working again.

This branch is for use with CakePHP 5.0+. For details see version map.

Installation

Please see Install.md

Usage

Please see Docs.

A full overview of all shimming between versions can be found in the Wiki.

New shims

  • RequestHandler component for continued easier View class switching across the app
  • LegacyModelAwareTrait for loadModel() shimming
  • former Cake\Filesystem\File and Cake\Filesystem\Folder classes
  • ModifiedTrait for entities and detecting actually changed fields (not just touched with same value)

Note: AuthComponent lives on in 5.x via TinyAuth plugin if needed.

Existing shims from 4.x

  • Controller setup for components and helpers
  • Nullable behavior for better data consistency.
  • Table::field() support and fieldByConditions() alias to migrate to.
  • Still supports model properties $primaryKey, $displayField, $order, $validate, $actsAs and all relations ($belongsTo, $hasMany, ...) as it would be very time-consuming to manually adjust all those.
  • Auto-adds Timestamp behavior if created or modified field exists in table.

Helpful links

When planning to upgrade, you should look into official upgrade docs as well as the linked upgrade tool. They both contain tons of more ideas on how to get code aligned with the current direction of the framework to reduce friction in the long run. Also see my blog post dereuromark.de/2023/09/28/cakephp-5-upgrade-guide/.