Horacio Peña Mon Sep 20 01:42:36 -0400 2010

Subject: Multiple Model Directories??

Is it possible to configure phpactiverecord to use many model directories? I need this because I'm looking for an open source ORM to add to Laguna Framework, and the problem is that it is modular, and each app has many MVC mini-apps (modules).

Any thoughts?

Thanks in advance


Kien La Wed Sep 29 17:52:47 -0400 2010

No, that's not supported currently but honestly I don't think it would be too difficult to add that in. If you wanted to try and do that yourself.

Jacques Fuentes Wed Sep 29 21:11:35 -0400 2010

If you wanted to do this in a hackish manner: alter the activerecord_autoload function in ActiveRecord.php:

function activerecord_autoload($class_name) {
  # don't use the path you'd normally set in the config
  # $path = ActiveRecord\Config::instance()->get_model_directory();
  # $root = realpath(isset($path) ? $path : '.');

  $my_paths = array('/apps/first_app/models', '/apps/second_app/models');
  foreach ($my_paths as $path) {
    $file = "$path/$class_name.php";
    if (file_exists($file))
      require $file;
  }
}

Keep in mind this is a hack and nothing something either of us is going to help support. Also, if you did it this way you'd lose the capacity for namespacing your models.

Horacio Peña Wed Sep 29 21:56:19 -0400 2010

I can't hardcode the modules that are going to be used. Thanks anyway. I guess I'm going to use my own ORM, I started building it a few days ago and it is a lot of fun. =p

(1-3/3)