Skip to content
Mark Scherer edited this page Sep 28, 2023 · 19 revisions

CakePHP version map

Shim plugin branch CakePHP core PHP min
0.x [EOL] cake2 2.x PHP 5.4
1.x [EOL] cake3 3.x PHP 5.6
2.x cake4 4.x PHP 7.3
3.x master 5.x PHP 8.1

Shimming overview for a CakePHP app.

Generic

Useful links and articles:

Model

Before 2.x with Shim 3.x with Shim
field() fieldByConditions() field()
saveField() saveFieldById() saveField()
hasAny() exists() exists()
updateAll() updateAllJoinless() updateAll()
deleteAll() with callbacks deleteAllJoinless() deleteAll()
deleteAll() without callbacks deleteAllRaw() ?
find('first') by id with manuell exception get($id) get($id)
read() / find('first') by id without exception record() record()
exists() without explicit id existsById($id) / exists($conditionsArray) existsById($id) / exists($conditionsArray)
delete() without explicit id delete($id) delete($id)
save($array) save($array) saveArray($array)
$this->Behaviors->load() $this->addBehavior() $this->addBehavior
$this->Behaviors->unload() $this->removeBehavior() $this->removeBehavior
$this->Behaviors->loaded() $this->hasBehavior() $this->hasBehavior()
$this->... (alias, table, ...) $this->...() $this->...()

Controller

Before 2.x with Shim 3.x with Shim
$this->Components->load() loadComponent() loadComponent()
__construct() overwriting initialize() initialize()

View

Before 2.x with Shim 3.x with Shim
$this->Html->url() $this->Url->build() $this->Url->build()
  • Start using JsonShim instead of Json view to have 3.x default of how to encode output (otherwise BC break when migrating).

Routing

in URLs

  • ext => _ext
  • full_base => _full

to avoid those silently failing when upgrading.

Security

Migrate to 3.x defaults without BC breaking changes.

  • Using FallbackHasher in 2.x already.

Testing

For Controllers use ShimIntegrationTestCase instead of ControllerTestCase in 2.x to easily upgrade those without changes to 3.x IntegrationTestCase.

More

And of course lots of deprecation warnings that can be enabled to find hidden issues that will often silently break when upgrading. Better to get rid of them before!