CakePHP 3.0.0-beta2 released

One month after our first beta release we are ready to ship the next batch of features.

The CakePHP core team is proud to announce the second beta release for CakePHP 3.0.0. It’s been a month since our first beta release, and we are excited by the big welcome the community has given to the new version. All the positive feedback and help has been a great motivation for the core team to work harder on improving the developer experience for 3.0.

This will be the last beta release for 3.0, this means that the API is already stabilizing and we’re mostly focusing on polishing the current features, performance optimizations, documentation and quickly solving any issues reported in Github.

We’ve had a very busy month implementing a few missing features we had in our roadmap and upgrading some of the popular plugins for CakePHP.

Below the list of new features and changes that made it into 3.0.0-beta2:

DebugKit

Debugging CakePHP 3.0 applications is even better. The new DebugKit is easier to install, faster and looks gorgeous.

DebugKit is a application toolbar that collects useful statistics about your code such as time and memory, executed queries, log messages and view variables. To install Debugkit just use

 `
composerrequirecakephp/debug_kit"3.0.*-dev"

`

And add this line to your bootstrap.php file:

Plugin::load('DebugKit', ['bootstrap' => true]);

If you install a new application using the app skeleton, DebugKit will be automatically installed for you.

Database Migrations

Migrations is now an official CakePHP plugin. It wraps the excellent Phinx library into a CakePHP shell to avoid repeating configuration strings and add some of the cake experience. A database migration generated by this plugin would look like:

<?php
use Phinx\Migration\AbstractMigration;
class CreateUsersTable extends AbstractMigration {
    /**
     * Change.
     */
    public function change() {
        // create the table
        $table = $this->table('users');
        $table->addColumn('id', 'integer')
            ->addColumn('username', 'string')
            ->addColumn('password', 'string')
            ->addColumn('created', 'datetime')
            ->create();
    }

Migrations are reversible. This means that with the same code you can create or rollback the changes done to the database schema.

To install the Migrations plugins run:

 `
composerrequirecakephp/migrations"dev-master"

`

And add this line to your bootstrap.php file:

Plugin::load('Migrations');

New Logger interface

CakePHP has adopted the PSR-3 recommendation for loggers. Now all log engines implement the ` PrsLogLoggerInterface`interface. This means that the entire logging system can easily be replaced by other implementations, such as the popular Monolog library.

Integration Tests and Data Integrity

Testing controllers has always been problematic. While ControllerTestCase solved some of the problems, we identified this class as a source of problems and confusion among our users. We decided to implement the new IntegrationTestCase class as a way totest all aspects of an HTTP request in your application without much mocking being involved. This should help you improve code quality and ensure that your application and routes are working as expected.

We also made the fixtures system better, allowing developers to define and work with foreign key constraints in their database. The fixtures system will now correctly load all data and enable constraints right before your test code is executed.

New Bake templates

With the date for a stable release getting closer and closer we decided to give a new look to default baked applications. Hopefully the new look will feel fresher, more modern, and easier to work with.

Separate packages

We’ve seen an increasing interest in using the new ORM outside the framework or within older CakePHP applications. One of our goals since the start has been making this possible. We have already begun the work to split the framework into various standalone components that can be reused and installed with composer. While the ORM has not yet been extracted into its own repository, most of the necessary pre- requisites are complete. As a product of this work, we have already extracted several components out of the main code base:

  • Collections: Provides a set of tools to manipulate arrays or Traversable objects in an efficient and elegant way.
  • Validation: The excellent and flexible validation library can now be used in any project!
  • Utility: Provides the Hash, Inflector, String and Xml classes.
  • Event: Our Signal-Slot (or Observer Pattern) implementation.
  • Core: The CakePHP core, containing the Configuration and Plugin management classes.

It is important to note that the these repositories are read-only, development will continue in the main CakePHP repository and code will be synchronized regularly to these splits. Please open any ticket or pull request directly in the main github repository.

Plugin Shells

Shells in plugins can now be called without prefixing with the plugin name. For example for a do_stuff shell living in the Tools plugin, you can execute:

 `
bin/cakedo_stuff

`

Other improvements

  • New uploadedFile validation rule.
  • Made String::uuid() 3 times faster.
  • Better exception reporting on fatal errors.
  • Inflector was optimized for better performance.
  • Several optimizations in the Hash class.
  • Added Collection::buffered() to transform non-rewindable iterators in rewindable ones.

Community Plugins

More plugins for version 3.0 are starting to pop. Here’s a list of what we found interesting:

  • TwigView Use Twig as the default templating engine.
  • Imagine Image manipulation plugin
  • Geo Contains utility libraries and behaviors for working with geo data.
  • Blame Records the user id who modified a row in the database.
  • CakePdf Generates PDF files using different engines
  • Authenticate Authorization and Authentication adapters
  • TinyAuth A lightweight authorization system.
  • TwitterBootstrap A plugin to generate Boostraped interfaces
  • Whoops Replaces the default exception renderer with a nice debugging interface.
  • Assetic Minifies and pre-processes CSS and Javascript We’d like to thank again everyone who has contributed thoughts, code, documentation or feedback to 3.0 so far.

Download the release

You can grab the packaged release here: cakephp-3-0-0-beta2.zip