Part of the EllisLab Network
   
1 of 2
1
Outlet ORM
Posted: 31 October 2008 12:42 PM   [ Ignore ]  
Summer Student
Total Posts:  9
Joined  10-17-2007

Hy guys,

I’ve been using this really cool ORM library called Outlet and I’d like to share how I managed to integrate it on CI. Since it is my first contribution to the community, just let me know if I’m doing anything wrong or forgetting something here.
Since english is not my native language, sorry about any incorrect use of words or mispelling.

—————————————————————————————————————

Here is the site and documentation. For this post, I’m going to assume that you’ve created your models and config file needed to get the libray working.

This is the folder structure I built:

../application/config
    
- outlet-config.php

../application/models
    
- models_include.php // file to include models
    
- ... models ...

../
application/outlet
    
- ... library files ...

../
application/libraries
    
- MY_Loader.php // Extends CI loader and adds a new method to load Outlet

To load the library, I extended CI loader and added this method

class MY_Loader
    
function outlet()
    
{
        
static $loaded = false;
        if (
$loaded) return;
        
        
// Includes models
        
include_once APPPATH.'/models/models_include.php';
                
        
// Sets outlet include path
        
ini_set('include_path', ini_get('include_path').';'.realpath(APPPATH.'/outlet'));
        require_once
'Outlet.php';
           
        
Outlet::init(include APPPATH.'/config/outlet-config.php');
    
        
$outlet = Outlet::getInstance();
        
$outlet->createProxies();
        
$loaded = true;
    
}
}

And to avoid name conflicts, I did a small change to the /system/codeigniter/CodeIgniter.php so that all controllers will need the ‘Controller’ suffix

....
/*
* ------------------------------------------------------
*  Security check
* ------------------------------------------------------
*  ...
*/
$class  = $RTR->fetch_class().'Controller'; // Here is the change
$method = $RTR->fetch_method();


if ( !
class_exists($class)
    OR
$method == 'controller'
...

I did that so that I can have a Order entity, an OrderController and still use a clean URL /index.php/order without any change to the CI core


I’m actually using the repository pattern but to make things simple, here’s a sample usage:

class OrderController extends Controller
{
    
function show($id)
    
{
        $this
->load->outlet();
        
        
$outlet = Outlet::getInstance();
        
$order = $outlet->load('Order', $id);
        
// display order data...
    
}
}

The ‘models_include.php’ file is really simple:

/**
* Include all models
*/

require_once 'Order.php';
require_once
'OrderLine.php';
// ... other entities ...

I hope you guys like it


Fábio Rehm

Profile
 
 
Posted: 03 November 2008 02:05 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  9
Joined  10-17-2007

For those using HMVC you have to modify the Loader inside the Controller.php file.


See ya,

Fábio Rehm

Profile
 
 
Posted: 12 March 2009 10:05 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  3
Joined  02-16-2009

What is your experience with this ORM?

Is it stable enough for production environments?

Any significant performance issues?

many thanks for sharing your solution

Profile
 
 
Posted: 13 March 2009 12:10 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  9
Joined  10-17-2007

Hi acpbl,

I haven’t used it on production enviroments yet but I’m about to launch an intranet that uses it.
I’m currently helping the library development and I can say that the main developer (Alvaro Carrasco) has been using it on production.

The thing to watch out for is changes to the API, since it hasn’t reached 1.0 it is still evolving.


Feel free to test the library and join us on Google Groups if you have any other questions.
http://groups.google.com/group/outlet-orm

Fabio Rehm

Profile
 
 
Posted: 22 April 2009 08:56 AM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  9
Joined  10-17-2007

Hi Guys,

I’m just dropping by to say that the 0.7 version of the library was released.

These are the new features:
  * One-to-one and many-to-many relationships
  * PHP-5.2’s DateTime support
  * Fluent-interface query API
  * Eager-fetching
  * PostgreSQL support

Check it out:
  http://www.outlet-orm.org/

Regards,

Fabio Rehm

Profile
 
 
Posted: 28 October 2009 08:54 AM   [ Ignore ]   [ # 5 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  596
Joined  02-04-2008

This looks very interesting.

I also have to say I like your change to codeigniter.php to force controllers to end in Controller while not indicating this in the url. This would be a great permanent change.

Profile
 
 
Posted: 29 October 2009 04:04 PM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  9
Joined  10-17-2007

I’m glad that you’ve liked it grin

We’ve been working on the 2.0 version on Github, there are some cool new features like Unit of Work and proxy caching. Just keep in mind that it is on a really early stage and it need to implement some features that we currently support on 0.7:
  http://github.com/fgrehm/outlet-orm

If you have any questions you can drop by our group:
  http://groups.google.com/group/outlet-orm


Regards,

Fábio Rehm

Profile
 
 
Posted: 17 November 2009 03:55 AM   [ Ignore ]   [ # 7 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  434
Joined  02-11-2007

This looks very interesting. It seems pretty similar to Doctrine though, how does it compare? From the docs it seems it handles relationships nicely grin

 Signature 

blog&business;: bybjorn.com - Premium ExpressionEngine 2.0 Themes - contact me on twitter: twitter.com/bjornbjorn

Profile
 
 
Posted: 17 November 2009 05:13 AM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  434
Joined  02-11-2007

Ok, just a little update, fgrehm answered my question on Twitter:

* well, Doctrine < 2.0 is more like activerecord pattern and outlet like data mappers
* doctrine has more features than outlet but that actually makes us easier to use and give us better performance (never measured)
* and doctrine 2.0 query language is a lot verbose, they require u to use fully qualified class names, outlet supports aliasing
* aliasing stuff relates to outlet 2.0 version still being developed on http://is.gd/4WXK7

 Signature 

blog&business;: bybjorn.com - Premium ExpressionEngine 2.0 Themes - contact me on twitter: twitter.com/bjornbjorn

Profile
 
 
Posted: 17 November 2009 08:39 AM   [ Ignore ]   [ # 9 ]  
Grad Student
Avatar
Rank
Total Posts:  84
Joined  04-04-2007

I like the fact that Outlet doesn’t require your objects to be extended.

Also for being lightweight, it sure is faster than Doctrine?

 Signature 

Programming is both a science and an art.
——
http://twitter.com/MarcoBarbosa
http://marcobarbosa.com

Profile
 
 
Posted: 17 November 2009 02:43 PM   [ Ignore ]   [ # 10 ]  
Summer Student
Total Posts:  9
Joined  10-17-2007

@bjornbjorn
  Thanks for posting my reply here :D

@M4rc0
  I can’t tell you 100% that it is faster and how faster it is. The fact that we use plain PDO and that we are not using reflection makes me believe in it. I know that have a PECL extension that does the hydration using C code but I’ve never tried it.

If anyone is interested in doing this benchmark don’t forget to show us the results :D

Regards,

Fábio Rehm

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 721, on January 06, 2010 09:38 AM
Total Registered Members: 115026 Total Logged-in Users: 62
Total Topics: 122461 Total Anonymous Users: 2
Total Replies: 647368 Total Guests: 449
Total Posts: 769829    
Members ( View Memberlist )