5.1.6

Latest release in branch 5.1
Released 1 year ago (February 23, 2025)

Software CakePHP
Branch 5.1
First official release version 5.1.0
First official release date 1 year ago (September 14, 2024)
Supported
PHP versions
PHP 8.1+
Release notes https://github.com/cakephp/cakephp/releases/tag/v5.1.6
Source code https://github.com/cakephp/cakephp/tree/v5.1.6
Documentation https://book.cakephp.org/5/en/index.html
Download https://book.cakephp.org/5/en/installation.html
CakePHP 5.1 Releases View full list

What is New in CakePHP 5.1

CakePHP 5.1 is a minor release that adds useful features while keeping backward compatibility with 5.0. It introduces new database types, validation rules for enums, type-safe casting functions, and better event handling. This version also includes several behavior changes for improved consistency and deprecations to prepare for future updates.

Core and Utility Enhancements

  • New type-safe casting functions: toString(), toInt(), toBool(), toDate(), and toDateTime() return null on failure.
  • pathCombine() utility to join paths without duplicate or trailing slashes.
  • Components now support dependency injection in constructors, similar to controllers.
  • New events in BaseApplication and BasePlugin for global listeners.
  • PluginConfig class to retrieve plugin metadata and versions.

Database and ORM Updates

  • Support for geospatial types: point, linestring, polygon, and geometry.
  • New query methods: SelectQuery::intersect() and SelectQuery::intersectAll().
  • Buffered results methods restored: enableBufferedResults(), disableBufferedResults(), and isBufferedResultsEnabled().
  • Optional JSON mapping for SQLite columns containing "json" in the name (opt-in via config).

Validation Improvements

  • New rules for backed enums: Validation::enum(), Validator::enum(), Validation::enumOnly(), and Validation::enumExcept().

HTTP and Server Features

  • HttpClient emits beforeSend and afterSend events.
  • Http\Server emits Server.terminate event.
  • SecurityHeadersMiddleware supports setPermissionsPolicy().

View and Helper Additions

  • View cells emit Cell.beforeAction and Cell.afterAction events.
  • HtmlHelper::meta() can generate CSRF token meta tags.
  • TextHelper::autoLinkUrls() has new options for stripping protocol and truncating long URLs.
  • New BannerHelper for formatted console banners.

Console and Cache

  • New command: cake plugin list to show loaded plugins.
  • Optional command arguments support default values.
  • Redis cache engine supports TLS connections.

Testing and Other Tools

  • Updated PHPUnit requirement to ^10.5.5 or ^11.1.3.
  • New LogTestTrait for asserting log messages in tests.
  • IntegrationTestTrait::replaceRequest() added.
  • Number formatting supports roundingMode option.

Behavior Changes

Several adjustments for better consistency:

  • Connection config creates unique read/write drivers if keys present.
  • FormHelper no longer adds aria-required on required inputs.
  • Duplicate association names raise exceptions.
  • Truncation methods use UTF-8 ellipsis.
  • Cache group hashing updated (may cause temporary misses).
  • Table::findList() uses space as default separator.

Deprecations

  • _cake_core_ cache key renamed to _cake_translations_.
  • Mailer::setMessage() deprecated.

Why Upgrade to CakePHP 5.1

CakePHP 5.1 adds practical features for modern development, including better database support, validation, and events. It maintains compatibility with 5.0 while introducing improvements that make code safer and more efficient. Developers can take advantage of new tools without major rewrites.

Releases In Branch 5.1

Version Release date
5.1.6 1 year ago
(February 23, 2025)
5.1.5 1 year ago
(January 17, 2025)
5.1.4 1 year ago
(December 13, 2024)
5.1.2 1 year ago
(November 10, 2024)
5.1.1 1 year ago
(October 04, 2024)
5.1.0 1 year ago
(September 14, 2024)
5.1.0-RC2 1 year ago
(August 08, 2024)
5.1.0-RC1 1 year ago
(May 21, 2024)