AugmentedCI: CI package extended with ORM, caching, PHP5 autoloading, Modular Seperation and UhOh exceptions |
[eluser]Jelmer[/eluser]
The great thing about CI is also what sometimes makes it a bit less great: it's very simple. It's not that it can't take on big projects but it takes a bit of extending. I've been maintaining a collection of libraries I use for almost every project nowadays and recently started intergrating them from the system directory instead of the application. While it is a grevious sin in many ways, it simplefied updating sites with multiple applications and also made sure I have less risk of accidently overwriting application libs/helpers/modules. I made it public pretty much because it is anyway since I started maintaining it on BitBucket. It is a package very much of my own preference so I won't change libraries because someone suggests if it doesn't suit my needs. But maybe it can benefit others anyway. At this point the package includes: - RapidDataMapper ORM (from m4rw3r) - MP_Cache for partial caching - Modular Seperation (from wiredesignz and Phil Sturgeon) - UhOh! Exception handling (from Dan Horrigan) - PHP5 autoloader - Alternate syntax for CI ("AugmentedCI helper") - Setting to switch off keeping everything referenced in models and controller (explained in post number #4 below and on BitBucket) It comes with some more conventions then CI has, but in exchange it gives you autoloaded interfaces, abstracts and exceptions: - Model classnames are always prefixed with "Md_" - Abstract classes go into APP/abstracts/ and are prefixed with "Ab_" - Interfaces go into APP/interfaces/ and are prefixed with "It_" - Exception classes go into APP/exceptions/ and are postfixed with "Exception" You can view the source and download it from: http://hg.mijnpraktijk.com/augmentedci
[eluser]Eric Barnes[/eluser]
Not bad. One question I have is what is "Alternate syntax for CI"? I tried searching but I am not finding anything. ![]()
[eluser]Eric Barnes[/eluser]
Thanks! That is very cool and I have not seen it before. I can see that coming in handy down the road.
[eluser]Jelmer[/eluser]
I just made an update some others might find usefull. (commit 39 , commit 40 & commit 41) CodeIgniter keeps references to all your libraries in your controller and in all you models. While that nicely facilitates using everything through "$this->libname", it also contaminates namespace of the objects in my opinion. And as the AugmentedCI helper syntax gives you another way to fetch libraries with "Ci::lib('libname')", you don't really need that anymore. I now made a new class CI_instance which keeps all those references and a modified Controller class which no longer extends the CI_Base. This makes for clean controllers with no other properties or functions in there unless you put them there through a MY_Controller. This would also make it possible to load Controllers from Controllers (theoraticly, as I haven't tested it), though I wouldn't recommend that unless you're experienced and know why you're breaking normal MVC. There's also a change to the Model class where _assign_libraries() does nothing anymore. Because I don't have the time to check all my current apps for any leftover $this->session type of code I added a __get() function to both Model and Controller which will see if the CI_instance object has a variable not found in the Model or Controller - thus making sure normal "$this->" syntax still works. But the use of __get() can be switched off by a config value, thus making sure anything you request from you controller/model is really from that object and not from the superobject.
[eluser]introvert[/eluser]
Why did you decide to go for RapidDataMapper? I've been using overzealous datamapper and I'm really satisfied with it. Whats the difference betwen them?
[eluser]Jelmer[/eluser]
I tried both and I really liked that RDM returns clean objects and has the CRUD part seperated from the data. Also the mappers are built in real time and after they're cached lots of queries don't have to be generated anymore and it becomes very fast. But it's been a while since I made the choice so I can't remember everything. In the end my choice was mainly technical/philosophical, and even though it's still pretty young I found it to be very reliable. Technical because I like how it works and has implemented many programming patterns in a very good way. And philosophical because of the clean data objects.
[eluser]kaejiavo[/eluser]
Hi Jelmer, i managed to integrate doctrine into my ci project but i am not quite happy with the structure , so i would like to give AugmentedCI a try. In the RapidDataMapper Manual i found: Quote:This is a simplified picture of how a CodeIgniter application using RapidDataMapper might look like: I understand that the page_model is my classical ci model and that page_obj and page_objdescriptor are the RDM models. But what i cannot figure out: - How do i use the RDM models from the page_model? - What have the page_obj and page_objdescriptor to look like? Can you give a simple example how to retrieve a record / object? TIA Marco
[eluser]Jelmer[/eluser]
m4rw3r wrote some good examples in the RDM forums: Quick start with CodeIgniter Along with the Manual you can probably figure it out.
|
Welcome Guest, Not a member yet? Register Sign In |