Revision [17396]
This is an old revision of WikkaCake made by BrianKoontz on 2007-08-11 22:00:48.
Integrating Wikka and CakePHP
Why use both?
I advocate the use of Wikka as a FlexibleWikka presentation framework for rapid development of Internet-based applications. Wikka does a great job of handling user authentication, session tracking, and presentation, but does not offer much in the way of easily customizable, high-level database read/write access. Enter CakePHP: A rapid-development PHP framework that handles many of the low-level DB access details so you don't have to. While Cake itself offers similar framework functionality as Wikka, my goal was to implement a totally self-contained Cake application within Wikka. The look-and-feel would be all Wikka, while the Cake engine would provide a database abstraction layer independent of Wikka.In addition, I'm a big fan of the MVC (model-view-controller) architecture, as it helps with cleanly delineating database functionality, business logic, and presentation. Cake is based upon the MVC (3-tier) model, while Wikka is better classified as a 2-tier model (database and business logic represented by one layer, presentation by the other). It's my belief that Cake could be used as a "plugin" framework that Wikka so badly needs. What follows is my proof of concept of one such implementation.
Goals
The goals for this project were simple:- No changes to the Wikka core libraries were to be made.
- No changes to the Cake core classes were to be made.
- Any modifications required to accommodate a Cake plugin were to be independent of operating system platform.
- No animals were to be harmed during this exercise.
I believe the first three goals have been met (and my three dogs are still happy with me, so I'm confident goal #4 was met as well).
Project platform
My development environment consists of Mac OSX 10.3.9, running the latest WikkaSVN trunk version of Wikka. The Cake version I'm currently using is 1.1.16.5421. Please be aware that Cake versions starting with 1.2 have significant API changes that may not be compatible with the setup instructions that follow. I have not tested this setup on Wikka 1.1.6.3 or earlier, but other than some directory restructuring, I see no reason why these instructions won't be applicable to earlier Wikka versions.It's almost a certainly that mod_rewrite MUST be enabled AND operational. This is because Cake (much like Wikka) depends upon the structure of the URL to determine what action gets called. Since both Cake and Wikka (when mod_rewrite is enabled) depend on the same mechanism, there is an inherent conflict that must be resolved by some creative tinkering with the Cake dispatch mechanism. If that was just a bunch of Greek to you, trust me on this: You'll want mod_rewrite enabled!
Installing Cake
Download the latest 1.1.x version of Cake and use whatever method is appropriate for your system to unzip/untar the Cake distribution to your 3rdparty/plugins directory. As a matter of convenience, Unix/OSX users may want to either create a symlink to the cake distribution directory:ln -s ./cake_1.1.16.5421 cake
or simply rename the directory:
mv cake_1.1.16.5421 cake
Windows users will have to opt for choice #2, as Windows does not support symlinks.
Cake is distributed with its own CSS stylesheet; many of the selectors conflict with the Wikka CSS selectors. As you will see shortly, there is a method that can be invoked in Wikka to include an external stylesheet in the <head> section that's generated by Wikka. I would recommend, at a minimum, that the Cake default CSS file (located at 3rdparty/plugins/cake/app/webroot/css/cake.generic.css) be copied to your Wikka css directory. Then, delete all sections but the section marked .
(If you decide you don't want to do this, there's a strong likelihood you will not see the error messages generated by the Cake built-in data validation methods!)