CakePHP
For a current project I joined the growing number of people using CakePHP. Even though I didn’t use any of the bakery options if found it mostly very useful.
Of course, there is the time spend to figure out how all fits together and I pssobily haven’t even touched half of the features.
One thing that I noticed, though, is the lack of consistent documentation. I mean, there is lots out there, but usually the stuff that breaks is so specific that it really takes a while to find the answer. On the other hand the CakePHP newsgroup was more then helpful for me.
There were two big issues I had so far:
1) Upload progress bar.
Thi si snot really CakePHP specific, but it took me a while to figure out how to tell the controller to not use a layout and view. But then, I usually prefer to read sources rather than read documentation.
But before it came to all that there was the realization that PHP doesn’t really make it easy to do that at all. As of PHP5.2 there is basic support, but even then it requires to install an extension in order to be able to really doe something useful.
Further complications are that the code seems to be less reliable on Windows installations. After some late nights experimenting with the sample code of the extensions author I tried an alternative demo which finally worked.
Still, it took me a ling time to figure out why my upload form wasn’t working when the demo could do it.
Two things really stand out here:
- The form needs a (hidden) MAX_FILE_SIZE field.
Interesting is that the value that works is 411353512 which I believe is the default value. It doesn’t matter if PHP is configured differently. Even though I was able to upload larger files, increasing the value broke the upload progress extension (or PHP) - Each file input field needs a (hidden) UPLOAD_IDENTIFIER field with a unique value. That value is then used to track progress.
Again some very interesing things here. First of all the identifier field has to be right before the field input, it’s no use putting them all at the begin or end.
The secod thing which took a lot longer to realise was that in order to work an additional identifier field was required after the last field input.
2) Session handling
Once I had the progress tracking basically working I ran into the next problem. Even though everything was working fine when doing it manually, tracking progress using Ajax caused the session to expire.
More experimenting showed that parallel or overlapping requests would cause the same problem. So, hitting reload a few times would make the session invalid!
This is where the CakePHP newsgoup kicked into action. After some very speedy responses and quick testing it turned out that the setting Security.level was the culprit.
It seems that recently the code was changed so the high setting would regenerate the session id for each request! that means with parallel requests the session id gets lost!
To sum it all up: I think CakePHP is really useful and does a lot of stuff assuming (rightly so) that most web apps works pretty much the same (login, authentications, sessions, forms, htm you name it).
However, once you need something more individual it takes a while to dig out all the nitty gritty details needed to make it do exactly what you want.
