views:

88

answers:

3

Hi everyone!

I am using this awesome framework during 6 months and I learnt a lot about it, but I wonder if it's possible to create an internal structure to simulate modules like in Codeigniter. I know there is the possibility to use plugins for that, but it seems too difficult to connect it together and pass info between them.

My goal is to get a joomla like modules, but how can i do that without changing the cakephp core? is that possible?

A: 

Well, you are right. Modules in Joomla are independent packages of code wich works like packages in linux (modules maybe depends on other modules), but all of them work over a core functionality. What I want to do is write a core over the CakePHP framework, wich includes the functionality to manage all kind of modules in the system, but I don't know what is the best way to modify CakePHP core to handle this situation...

I did this before with Codeigniter, and because of that I thought to come back to Codeigniter, but Cakephp helps me to create apps in less time... If it may be possible, it would be a great system.

Every module code should be inside its own directory, which includes a controller directory, models, views, config, etc... like a mini CakePHP app that extends the modified CakePHP core. I thought it can be done with plugins, but the way to interconnect them and pass info between them don't seem the best way to do it.

I hope you understand my explanation, sorry for my english.

xterico
Welcome to SO! :) You should not post clarifications to questions as answers, rather, please update your question. It also lets your question appear *unanswered*, which may help draw attention to it. Having said that, what kind of "interconnection" were you thinking about? AFAIK (not having used plugins much) you can use other plugins within plugins and [use `requestAction` for inter-controller communication](http://book.cakephp.org/complete/1111/Plugins#Plugin-Tips-1118), so a concrete example of what you're missing would be good.
deceze
A: 

What I am doing for the project I have going on right now is to have the following

In my bootstrap.php

<?php
    ....
    App::build( array(
        'plugins' => array(
            join( DS, array( null, 'Users', 'abryant', 'Sites', 'appName', 'tools' )),
        ),
        ...
    ));
?>

Then, I keep all of my utility plugins in the tools plugin folder. This is for plugins that you use as internal utilities that don't provide controller / action pairs. IE plugins for behaviors, components, stuff from github etc.

One of the plugins I always grab for my stuff is Eventful which allows you to handle event dispatching and receiving using event classes similar to controllers or models.

Then build a main AppController that has a corresponding AppControllerEvent class in the folder the instructions tell you to use. You can then keep your plugins folder clean for modules which provide controllers, views or some other direct user interaction.

You can use Eventful to broadcast events from plugins down to the App at the AppModel, or AppController sort of level. If you think about this carefully you can use an app level event to ask for responses from installed plugins and then cycle through a set of events to register blocks or inject information into the set view variables.

A lot opens up when you use events and think about how the events communicate with your app.

Abba Bryant
A: 

Initially it seems very difficult, but I think it is the best solution for this problem.

Did you code plugins for all your modules? Or did you code the core in controllers, models, etc.. and extra modules inside plugins? It is weird to me to work this way in CakePHP.

I'll try to code all the modules apart, I mean a core plugin, settings plugin, modules plugin (to manage the other plugins), etc... And probably I'll use bootstraping.

Thank you very much for your answers and sorry for my bad explanation of my problem, but my idea was so general that I couldn't explain it better.

xterico
Please use *comments* for comments, not *answers*. Thanks.
deceze
Sorry for that, I'll do next time. Thank you.
xterico