dereuromark/cakephp-shim

A CakePHP plugin to shim applications between major framework versions.

Installs: 185 686

Dependents: 4

Suggesters: 0

Stars: 34

Watchers: 2

Forks: 10

Open Issues: 3

Type:cakephp-plugin


README

Build Status 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 2.x in 3.x (and preparing for 4.x)

It provides compatibility wrapper access to 2.x functionality in 3.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.

It also contains useful 4.x preparation shims.

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

Installation

Please see SETUP.md

Usage

Please see Docs.

A full overview of all shimming between 2.x and 3.x can be found in the Wiki.

Main shims

  • Common component and Nullable behavior for better data consistency.
  • TraitCast for clean and safe request handling.
  • Auto-adds Timestamp behavior if created or modified field exists in table.
  • Get/Read trait for clean and speaking entity access.

Backwords Compatibility shims

Only for 2.x => 3.x shimming: Ccontinue to provide support for some 2.x functioality in 3.x.

  • Contains Session component as compatibility wrapper for request session object (and Session helper).
  • Primary level Table::find('first') support.
  • Primary level Table::find('count') support.
  • 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.
  • Shims controller $uses with deprecation warning.

Forwards Compatibility shims

For 4.x compatibility of 3.x apps: Make your 3.x app future proof.

  • Controller referer() local security fix
  • BoolType, StringType, DecimalType, JsonType behave like in 4.x
  • Table newEmptyEntity() method available

Deprecation help

For 3.x => 4.x: Report early on about what can be changed to prepare for 4.x.

  • UrlHelper::build()

Helpful links

When planning to upgrade, you should look into the upgrade plugin for 2.x and upgrade app for 3.x. They both extend the core ones and 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.