Category Archives: cakephp

Don’t forget to exit after a redirect

Last weekend I discovered something I was not aware that it works that way: that code defined after a redirect is executed. A simple example: class UsersController extends AppController { function beforeFilter() { // not logged in, so redirect to the login page $this->redirect(‘/login’); } function delete($id) { $this->User->delete($id); } } This example redirects _and_ […]

findABaker job board started

This week there was a discussion in the IRC channel about a missing job board for cake related jobs. VoilĂ , here it is: findABaker. Feedback is as always welcome :) Btw: I switched to a minimalist blog theme which should fix the issues with displaying code snippets in some browsers (and it is a good […]

Selecting data in a specific date range

Sometimes, you have to return all objects created in a specific date range, e.g. you want to return all posts created in the last thirty days. Thanks to the nice functions for date operations provided by MySQL this task is simple: $this->Post->findAll( ‘WHERE Post.created >= DATE_SUB(CURDATE(), INTERVAL 30 DAY)’);

YAML in a cake? No, thank you!

While implementing fixture support in the testsuite the question arised which format should be used for the fixtures? The first answer was: YAML, of course. It is used in Ruby on Rails, so it cannot be bad ;-) Hm. Let’s have a look at a simple YAML example: // urls.yml cakephp: id: 1 name: CakePHP […]

Updating multiple divs with Ajax. Without crashing Firefox

In an earlier post I showed you how you can update multiple divs with Ajax. But there was one problem: it crashed Firefox on my machine, and other people reported the same problem, whereas it worked for others… In a comment, Josh Southern, pointed me to the cause of the problem: the “latest” version, 1.4, […]

Take over the “control” of some urls from CakePHP

By default, CakePHP takes full “control” of all URLs at the point where it is installed. Sometimes that behaviour is not desired. For example, my hoster defines an url like mydomain.com/stats where the statistics are available. If I install CakePHP in the root, this url no longer works resp. causes an error in CakePHP. The […]

Testing a cake – what’s missing?

In the last few days I discussed with several people about (unit) testing in CakePHP. The result is that testing with CakePHP is not as easy as it should be (not really a surprise if you ever tried to write tests *g*), and that some features are missing. So here my current todo list for […]

How to use multiple AppModels?

CakePHP supports just one custom AppModel, which must be placed in the /app folder. If you place another AppModel in the app folder and you try to extend your model from that AppModel, you get a “Class not found” error. To avoid that error you simply have to add a require statement at the top […]

Why are there two “vendors” folders in CakePHP?

You probably noticed that there are two “vendors” folders in CakePHP: one is directly in the root and the other in the “app” folder. So, why are there two such folders? It is simple. The “vendors” folder in the “app” folder is for application-specifc third-party libraries whereas the other “vendors” folder is for libraries you […]

Using Zend Framework Components in CakePHP

Yesterday, A/R/T has published my article I wrote some time ago about using Zend Framework components in CakePHP. In that article a very simple application is created which uses the Zend_Service_Flickr component to access the Flickr webservices.