The day I learned CakePHP, it started inspiring me for getting more and more out of it. Its custom hacks are pretty cool, and CakePHP is a complete framework in itself. However, like all other frameworks, it creates too much of work when we have to code some features again and again, like User-registration, a link manager, gallery and all.... Joomla does handle all this pretty well. So, after I saw Drake, I decided to write my same thing with Joomla as I like it as a CMS and it is used by us everyday.
I would like to thank Felix from ThinkingPHP the most, his research helped me a lot to do this.
Let's start with a nice fresh setup.
1) Download Fresh versions of Cake and Joomla
and install Cake first (for me its joomla_cake), Rename cakephp's /app/webroot/index.php to cakephp.php then install Joomla inside 'webroot' of Cake's directory.
So your directory structure will be like:
/app
---------/webroot
-----------------/joomla's index.php with other files
-----------------/cakephp.php (we will use this to triger Cake)
/cake
/vendors
Edit cakephp.php
-
{
-
}
-
else
-
{
-
/* $Dispatcher= new Dispatcher ();
-
$Dispatcher->dispatch($url);*/
-
}
Now we have disabled page rendering if we include this 'cakephp.php' in any external application.
2) Lets Create Joomla Component which will trigger Cake. : Lets call it 'com_cake'. This will be our master component in Joomla which will be triggered in case of when any unidentified Joomla's component is called... Lets add this functionality first.. Edit Joomla's index.php:
-
//Before Joomla initialize its mainframe, lets play...
-
// check missing component -- added before $mainframe is being initialized
-
//##########################
-
$option='com_cake'; //set component to com_cake if a controller is not found.
-
//##########################
-
$mainframe = new mosMainFrame( $database, $option, '.' );
Lets get back to create the component:
/app
---------/webroot
-----------------/components (Joomla's component dir)
------------------------/com_cake
----------------------------------/cake.html.php (trigger to cakephp)
----------------------------------/cake.php (calls trigger with required options)
/cake
/vendors
We have to follow Joomla conventions for this module...
Lets create these 2 files, cake.php and cake.html.php:
cake.html.php:
cake.php: This file will judge which controller/action to pass in cakephp.
-
require_once($mainframe->getPath('front_html'));
-
$mainframe->setPageTitle("Check this out");
-
global $database;
-
$controller=mosGetParam( $_REQUEST ,'option'); //option passed is treated as a controller in cake
-
$action=mosGetParam( $_REQUEST ,'task'); //task passed is treated as a controller in cake
-
HTML_cake::requestCakePHP('/'.$controller.'/'.$action);
3) Time to check its functioning:
www.myserver.com/joomla/index.php?option=names&task=add
1. $_GET['option'] is passed to Joomla's index.php. There it concluded that component called 'names' is not found, so lets pass it to 'com_cake'
2. Now we are in cake.php (com_cake), we will check what controller and action it is requesting, and trigger the 'requestCakePHP' function.
This will make Joomla to assume that component being called is 'com_cake', and task is 'names/add'. This task will be then passed to Cake as $_GET['url'].
And we're done...
I see baked code of Cake's model 'name' inside Joomla.
Currently, I have not created it to handle the function arguments... but if I found this to be more useful... I will continue the project. The next updates will be:
1. Better handling of function arguments.
2. Customization of CakePHP's helpers to make use of right path and more.
3. Utilization of some plugins
Thanks
-- Max aka Abhimanyu Grover
on Mon, 29 January, 2007 at 5:06 am
Max - this is indeed cool and I appreciate you sharing these instructions with the community. I blogged it for others to see, too! Thanks so much!
http://AmyStephen.us/index.php/2007/01/28/do-you-want-any-joomla-with-your-cake/
on Mon, 29 January, 2007 at 5:50 am
Do you want any Joomla! with your Cake?…
Very cool article written by Abhimanyu Grover (Max) entitled Joining powers of two great systems: Joomla and CakePHP.
In this, Max shows how to install Joomla! into the ‘webroot’ of Cake’s directory. And, then take full advantage of the MVC arc…
on Mon, 29 January, 2007 at 8:00 am
Very interesting article, but what about execution speed? Have you done some benchmarks? I think Joomla! is already slow in some cases (especially in bad-coded third-party components ). Do you think having the Joomla! framework wrapped by cakePHP framework could seriously slow down the speed of the entire CMS?
Sorry for my english and thanks in advance for any answer.
on Mon, 29 January, 2007 at 8:33 am
@Amy: Thanks a lot for posting about this. I’m now really excited to continue this…
@Xscratch: I have not done any benchmarking so far…. I know current setup might be slower than normal speeds, but to improve it I know how we can optimize it….
1. define(’AUTO_SESSION’, false); in core.php
Since Joomla has its own session handling, we dont need it in Cake.
2. Set Debug to 0
3. Disable the use of helpers which are loaded by default.
Read the real impressive comment made by phpnut (Developer of Cake):
http://www.sellersrank.com/php/cakephp-codeigniter-benchmark/#comment-36
It might not look successful for the big apps as of now, but optimizing this is really possible…
on Mon, 29 January, 2007 at 10:37 am
Ok, thank you for the quick reply and the time spent on this experiment
on Mon, 29 January, 2007 at 2:45 pm
Integrando Joomla en CakePHP…
En Giga Promoters explican como poner en funcionamiento el Joomla dentro de una instalación de CakePHP con muy pocos cambios.
Para quienes no conozcan, Joomla es un CMS que está en boca de muchos hoy en día, no lo he probado en detalle pero lo poco …
on Fri, 9 February, 2007 at 10:13 pm
Thanks about it Max! This was definately needed. I am going to try soon. I bloged about it in my personal website: http://phpmysqlapache.com/wordpress/2007/02/09/integrate-cakephp-with-joomla/
on Tue, 13 February, 2007 at 10:58 pm
Here is the better solution:
http://www.gigapromoters.com/blog/2007/02/13/finally-a-practical-solution-joomla-with-cakephp-together-jake/
on Wed, 20 June, 2007 at 5:59 am
Thanks for integration
Watch out for licence issues. I think ????
Cake is MIT …. Joomla is GPL
if you are creating applications for resale and linking to joomla it may be GPL. Joomla has big change just lately June 2007 about creating commercial extensions.
Me, no exper,t just stating a new fact to consider.