Yes! It is official. Cake PHP has finally been rendered stable. With the release of its latest version 2.3.0, Cake PHP has got a facelift which has introduced various iterations in the framework, which are compatible with the predecessor 2.2.5 as well. If this piece of news has given you an adrenaline rush and you are planning to shift your major development ventures to this upgraded version, then ensure that you read the migration guide thoroughly. This will ensure a smooth sailing as you will be aware of all the changes that your application may need.
If you are pondering over what changes might have been introduced in Cake PHP, then the answer is right here. Here’s a quick overview of some major iterations that have been introduced in Cake PHP 2.3.0.
Pagination has now become easier! If you wish to apply custom find method while giving pagination calls in your code, this latest version of Cake enables you to do so without much hassle. All you need to do is to set the findType key in the array in the settings segment and bingo! Another major development in the pagination section deals with user-application interaction. If a user tries to access a page that is out of range, the application will return a ‘NotFoundException’ error notification instead of serving a non-existing page.
We all loved AuthComponent, but always longed for something better. The better has finally arrived. The new version of framework comes equipped with AuthComponent::$unauthorizedRedirect property, which will make the implementation of authorization mechanisms a tad easier. Instead of sending the user to page showcasing non-existent access rights, the mechanisms will now respond with appropriate error codes. With the newly introduced property, you can add to mend this behavior at runtime and also set the value to a URL or false, as required. Furthermore, the community has flagged the use of AuthComponent::redirect() and favored using AuthComponent::redirectUrl instead, so that the working of the method is reflected in a better manner.
There has been tremendous improvement at the security front as well. The Cake community has introduced Blowfish adapter that turns your password into hash using bcrypt or blowfish.
All Love for PHP 5.4:
Yes! Your beloved PHP 5.4 is still there. But what comes as an icing on the cake is the release of cool shell command that enables you to create a standalone php server for rapid application development.
Custom View Classes:
Don’t you find the in-built implementation for content type views sufficing enough? Looking for ways to extend them? Well, this time around it is simpler than ever before. Just use requestHandlerComponent::viewClassMap() to set the name of view class or directly set the map for the RequestComponentHandler in the settings array.
Email and Networking:
Sending emails using the SMTP+TLS protocols has become easier than ever before. With the inclusion of TLS support it will become a piece of cake for you. Moreover, now you can use contentDispositionoption to add Content-Disposition header to the attachments sent with your CakeEmail. Another minor tweak was the deprecation of HttpResponse and transfer of its code into HttpSocketResponse.
Congratulations! Now you can read the data posted using querystring with the aid of method request- ->query(‘key’). Also, MediaView has been deprecated and all its code resides in CakeResponse::file(). So, all you need is a one-liner to send directly send files to the browser- either by making a download or streaming it online.
Helpers and Views:
Have you ever been stuck in a scenario where you didn’t know about the existence location of an element in advance? Well, 2.3.0 is here to pull you out. The View::Element has been upgraded and the community has introduced ignoreMissing option and View::ElementExists() to reduce the redundant appearance of missing element errors.
The view class has also received some degree of makeover. As per a significant change, View::fetch() will return a default text message in case the value of existing block is null. Also, prepending text to an existing block has become more handy, thanks to View::prepend.
Another minor yet significant change deals with the layout of Cake PHP. The layout of the framework now uses HTML5 as doc type. This change has been introduced because adding requisite attributes to the fields has become simplified because of the inception of FormHelper. PaginatorHelper has also got some noteworthy and highly anticipated features
About Author – John pitt is a blogger cum php developer for a leading PHP web development company which provides Offshore PHP Developer for hire. He provides concrete information about PHP, .Net/Java apps development, software development & mobile applications development.