CodeIgniter application package and loading the hooks

538 Views Asked by At

I'm building multiple sites, which are all connected together. Site A is a CodeIgniter application. Site B is a second CI-app, and I'm using the Application Package loader to use the models of the site A (which works, which is awesome: the registration/login procedure is built in site A, and works in site B too).

However, I have built a Hook in site A to set cookie/session data (about the origin of the visitor, which I'm storing upon registration). The problem is: the Hooks of site A are not loaded when using Application Packages. Does anyone have an idea of how I can get this to work? I can't load a hook (in hooks.php) in site B with a path outside the /application/ folder... Thanks in advance!

1

There are 1 best solutions below

1
On

Because of the way CI loads hooks, it assumes all the hooks are in your application folder for the currently running app. You have two options:

1) The only things that would work is hacking the CI core hooks code to make it use some sort of search array for valid hooks; difficult and not optimal since you won't be able to upgrade your site to late CI versions easily. This is your only choice if running on a windows host.

2) create a symlink in App B's hooks folder on the application folder to point to App A's hook file. You will also need to define the hook and enable hooks in App B in the usual way. This won't work on a Windows host.

Hope this helps. Good Luck!