CakeDC Blog

TIPS, INSIGHTS AND THE LATEST FROM THE EXPERTS BEHIND CAKEPHP

Migrations plugin 2.3.0 released

We’ve just released version 2.3.0 of the CakeDC Migrations plugin for CakePHP, and with it a couple of new features, a collection of bug fixes and improvements, an update of the code to 2.5, as well as a reformatting of the documentation, inline with the CakeDC Plugin Standard. For those who haven’t used the Migrations plugin, it’s an essential part of any CakePHP application. It helps keep the integrity of your database schema in check, managing changes as it evolves, and offers you a convenient and simple way to keep track of your database development. The migrations themselves are database agnostic, and all data sources supported by CakePHP are available. You can think of each migration as being a new "version" of the database. A schema starts off with nothing in it, and each migration modifies it to add or remove tables, columns or rows. Fields and tables can be renamed, and their data types can be modified as well within the constraints of the type conversion. Migrations can even be rolled back if needed. There is no more messing with arbitrary named SQL files, as migrations will provide you with a clear and comprehensive way of keeping track of your database changes, within the scope of your application code, as the migrations are a part of your application. As an example, and described in the Quick Start tutorial, generating your first migration is as simple as calling a shell command: $ cake Migrations.migration generate This adds the database migration to your application, which can then be shared with other developers on your team, or used by your deployment system to update your server. You could even use the plugin to create an application installer/updater. Running the available migrations is just as easy, and is also a shell command: $ cake Migrations.migration run all The plugin comes with numerous shell commands to control your migrations, and can be found in the documentation here. One of the new features included with this release is the ability to create migrations from the command line, without any database interaction. For example, we could create a "users" table, with an "id" field as the primary key, a "name" field as a string, as well as the standard "created" and "modified" fields, all via a shell command: generate create_users id:primary_key name:string created modified This is particularly useful for scripting changes to the database, and automating your update procedures. A special thanks goes out to Jose Gonzalez for his contribution! As always, our plugins are released as Open Source, free of charge, and benefit directly from the contributions made by the CakePHP community at large. We want to thank all of the contributors to the Migrations plugin, and hope that future involvement helps keep the framework ecosystem strong, with a host of powerful plugins that keep you all building awesome applications. Thanks!

CakePHP 2.5 and beyond

If you haven't heard yet, CakePHP 2.5 was just released, and with it comes a plethora of awesomeness, such as the new completion shell, the Memcached cache adaptor and support for Amazon ElastiCache, a simple AES-256 encryption API, improved email parsing and validation options, support for unsigned, numeric, real and decimal types, cross origin requests (CORS) and much more. Be sure to check out the changelogs, as well as the migration guide, for a full breakdown of the what's been introduced. With this milestone release, upgrading your code base is now more important than ever, as the framework heads towards a significantly mature and stable state. This directly affects your application, as you take full advantage of that stability, performance, security and a host of features, which help make your application the very best it can be. If you're still on an older version of the framework, and think you may face great adversity in migrating, but still really want to see you code running on the latest and greatest version of the framework, don't hesitate to contact us. Upgrading is vital if you want to stay ahead of the pack, and get the most out of CakePHP.

Plugins

As we mentioned in an article a while back, we've been busy upgrading our Open Source plugins for CakePHP with the CakeDC Plugin Standard. At the same time, we're targeting them at the latest 2.5 code base, while also testing against Travis CI for greater community involvement on code stability and integration. We encourage everyone who maintains a CakePHP plugin to also review their code, and revise that the changes in this latest version are compatible. And when you do, be noisy about it! Tell the world. Get it registered, and post around the CakePHP community. It's huge, and stretches across the globe. Only together can we make sure the quality of the framework and it's eco-system are strong and healthy, which benefits us all.

Contributing

If you're reading this, you probably use CakePHP, in either your own applications, or possibly at a company which uses the framework for client projects. Most of you may also be well aware of the active development that's currently going on with the third major version of the framework, and may have even played around with the developer preview releases of CakePHP 3.0, which were shared with the community over the past months. Over time, we've grown up with the framework, as well as others, and have helped advance the project to help everyone reap the full benefits of it's extraordinary rapid development. If you're actively involved with the framework, and using it regularly, then don't pass up on the chance to join in with the world wide community of contributors, who help build and shape CakePHP, making it what it is today. And that doesn't necessarily mean writing code. There are plenty of ways you can help out and get involved with the project, and in the process, help maintain CakePHP as the project that it's become over the last, nearly 10 years of it's life time. We're happy to be a part of this journey, and hope that you too join in for the next 10 years to come! The cake was never a lie.

The Imagine plugin

The Imagine plugin for CakePHP, which has been available from the CakeDC account on GitHub, was written as a separate plugin, but complementary to my FileStorage plugin. In the past, the old CakePHP 1.3 times, we've had our Media plugin which we never released. The main purpose of the plugin was to deal with file uploads, but only to the local system and to process images. I've had to work with a few client projects that used phpthumb, which I've learned to dislike because it had its faults and issues. Before reinventing the wheel I simply tried to ask if somebody knows about something modern, OOP, PHP 5+, with unit tests, and had some luck. Imagine is a modern PHP 5.3 library that provides an interface to different image processing back-ends like gd, imagick and imagick shell. Others can be implemented as well. I really recommend this lib over phpthumb, and suggest you to replace it with Imagine if your project is moving on. The plugin for CakePHP is basically a wrapper around the Imagine library, that will autoload the library (because CakePHP 2.0 does not have it's own autoloader until 3.0) and make it available as a behavior. The behavior provides some methods that handle commonly used image operations, like cropping and thumbnails. Besides that, the plugin comes with a helper and a component, which allows it to generate versions of images on the fly. This was more done for backward compatibility for some apps, rather than being a concept that should be used. In fact, it is not the recommended way to handle this. I've written two other articles related to image processing and file storage that explain the issues with that. Instead of creating images on the fly, which is just putting load on the server all the time, you should create the versions of an image after upload. The Imagine plugin works together with the FileStorage plugin, which can use Imagine to generate whatever images you want, right after upload. I originally contributed this plugin, which I developed in my own free time, to CakeDC. But now, it is finally going back to my GitHub user, to pull some maintenance work away from the company. I'll continue to maintain it, and hope you take some time to check it out, and contribute if possible.

The future of the CakeDC plugins

It has been more than 3 years now that we released our internal plugins as open source for the CakePHP community. Some of the first plugins released are now our most popular, like Users, Migrations and Utils. Most of the plugins were developed for version 1.3 of the framework. The later ones were just for 2.x, with the older plugins upgraded to 2.0. It is true that we have sometimes not been happy ourselves with the current organization of the branches and versioning of the plugins. This has been a lot to do with the legacy of the code, which comes over 2 major versions of the framework, and many years of active development. It is probably obvious to experienced open source developers that it's not easy to maintain and test the code for all and every available version of CakePHP. But, we've now spent some time discussing this internally and we are finally able to propose a solution we're happy with. These are the changes that will be made over the next months, to take us to version 3.0 of the framework:

  • Repositories: The branches for the plugin repositories will be updated, and we will focus on tags for releases. Each major and minor version of the framework will also have a development branch, like 1.3 or 2.2. The main develop and master branches will be for the latest version of the plugin, for the latest version of the framework.
  • Versioning: Our current versions are limited to 1.3 and 2.0. This will change, as we will adopt semantic versioning (http://semver.org), and plugins will follow a new version style, that is the core version and plugin version, like 2.3/1.2.1. This would be version 1.2.1 of the plugin, for version 2.3 of the framework.
  • Documentation: We've been working on building a dedicated API site for the CakeDC plugins, very similar to the same one for CakePHP. This should help developers access the technical documentation more easily. We will also be revising the README files for each plugin, as over the years some of these have become less well structured.
  • Testing: As always we take unit testing very seriously. In order to confirm the functionality of the plugins we will be providing build test coverage for each of our plugins on the supported versions of CakePHP, as well as varied versions of the PHP language. This will allow coverage to be viewed by anyone using or contributing to our plugins.
We hope that these changes will help make the CakeDC plugins more accessible and dependable for the CakePHP community. This is the perfect moment to thank everyone who has contributed to the code, helped resolve issues, or even just joined the conversation and provided input or criticism. A contribution can be a bug report or even a feature request. So do not hesitate to tell us via an issue on GitHub that there is something wrong, or you would like to see something useful added to a plugin. A contribution can even be improving the documentation or adding examples for other developers. If you're using our plugins, but don't think the README or API documentation supports your problem, don't hesitate in creating an issue on GitHub, as sometimes other developers can help you out. However, you can also find community driven help and support from the channels listed over at the community center. To get an immediate response the best place is always the #cakephp IRC channel on Freenode. We are frequently available at these locations, but mostly in our free time. Finally, we estimated until today that we have spent more than 600 hours developing and maintaining the CakeDC plugins, not including the time we spend reviewing or discussing issues. We provide these plugins for free, under the MIT open source license, while also providing professional support, in the form of integration or development services. These are just some of the many ways we contribute back to the CakePHP community.

Making great things even greater

If you ever have the time, take a few seconds of your day to check this out: https://github.com/cakephp/cakephp/commit/1e6c7b9d902d6867e3b475bb437eabe98c0acce3 Though this may seem trivial to some, it was a very significant moment in the history of the CakePHP framework. Over 8 years ago now, on the 15th of May 2005, the source code for the project was released under the MIT open source license. So, why was this so important? Simply because it was the first major step which got the project to where it is today. It's also been over 6 years now since the Cake Development Corporation was established by Larry Masters, founder of CakePHP, along side the now departed Michal Tatarynowicz and Kamil Dzielinski. Many well respected developers, as well as contributors to the project, past and present, have set foot in the company, delivering the very best of CakePHP in some awesome projects, while leaving their footprint in the process. And it not only counts for those on the inside, but also the developers from the community, who openly collaborate on the CakeDC open source plugins. These have been a long and colorful six years, full of roller coaster ups and downs, twists and turns, but it's not so much the "when it was created" that counts here, but the "why". Rewind back to 2007, and Larry's proposal was simple: to create a commercial entity which allows people to live and breathe CakePHP, doing what they love day-to-day, while also providing them with a means to support their financial obligations. That's it. Sounds simple, right? Ha! That's much easier said than done, and you’ll soon find out why. Over the coming months we'll be taking an in-depth look at the history and internals of the Cake Development Corporation, giving you a unique insight through a series of posts into how this singular company does business very differently. Hope you enjoy the ride!

We Bake with CakePHP