views:

164

answers:

2

in yii i could have mvc components (acts like an own application). could i have this too in codeigniter?

eg. in SYSTEM/APPLICATION have a folder called COMPONENTS and in there i put stand-alone applications that would be a part of the application. components like ADDRESS BOOK, MAIL, TWITTER and so on. every component folder has folders like: models, views, controllers, config etc.

so a component model extends the application model which in turn extends system's (code igniter) model. the same goes for view and controller.

i've already got a lot of these components which i want to use in codeigniter. is it good idea to place them as i said in SYSTEM/APPLICATION/COMPONENTS or is there best practice for this?

A: 

Not by default in CI 1.7.2, but 'packages' will be available in 2.0.

Added ability to set "Package" paths - specific paths where the Loader and Config classes should try to look first for a requested file. This allows distribution of sub-applications with their own libraries, models, config files, etc. in a single "package" directory. See the Loader class documentation for more details.

From: http://bitbucket.org/ellislab/codeigniter/src/tip/user_guide/changelog.html

Also, take a look at Modular Extensions - HMVC

Billiam
could you explain what the practical differences are between modules and packages?
never_had_a_name
Not well, as I haven't used either one.Packages will be part of codeigniter's next release, where the HMVC extension is 3rd party.It looks like CI's packages will consist of config, helpers, language, libraries and models, and are intended for loading from non-packaged controllers, where the extension has controllers that can be used to generate partial views, or can be run directly.Again, though, I haven't used either one and cannot be sure.Here's the CI 2.0 loader documentation: http://bitbucket.org/ellislab/codeigniter/src/812ab3fadc2f/user_guide/libraries/loader.html
Billiam
This is a terrible answer. Packages do not offer any sort of HMVC at all, and HMVC is a very old system which does not even work with CodeIgniter 2.0! Blog post incoming....
Phil Sturgeon
I was in the process of writing this anyhow. This will explain why you have it wrong. :-) http://philsturgeon.co.uk/news/2010/04/codeigniter-packages-modules
Phil Sturgeon
@Phil...u again:@ maybe you should make a comment about the age of Modular Extensions on the CI wiki. Cause it could be very confusing for new guys to understand that. Maybe mark it as deprecated or something and give a link to Modular Separation?
never_had_a_name
I updated the MS wiki page earlier today to explain some of the differences. I'll have a go at improving ME soon.
Phil Sturgeon
+1  A: 

You can do this in CodeIgniter using v1.7.2 or 2.0, but using Packages as Billiam suggested would not work and sadly he is just confusing you.

You are basically looking for a HMVC architecture and this can be provided with a system called Modular Separation.

That works with CodeIgniter 1.7.2 and I have patched it to work with the (still unfinished) CodeIgniter 2.0 branch on the link in the entry.

Phil Sturgeon
@phil sturgeon. great stuff!
never_had_a_name