Welcome Guest, Not a member yet? Register   Sign In
multiple codebases and appending paths for $this->load->library()
#1

[eluser]Unknown[/eluser]
Hey folks!

Not having much luck with my google-fu and forum searching. Maybe the answer is so overly simple I am overlooking it? Wink

So...

I'm wondering if there is an easy way to append a path to the Loader class.

For this example:

I have "4" different "projects" being maintained in version control:

1) "project_x" in /src/project_x/system/application/
2) "project_y" in /src/project_y/system/application/
3) "cross_project_lib" in /src/cross_project_lib/system/lib/
4) "code_igniter" in /src/ci/{standard CI dir structure goes here}

..where projects x & y codebases (1 & 2) are potentially developed independently, but would rely on a 'base' version of code-igniter(4) and a 'shared lib' codebase (3) which would contain cross-project common shared libraries and functionality.

In my current arrangement, I am able to get items 1,2, and 4 play well, but find myself stumped on looping in item #3, this "designed for CI, but not part of the CI project, but used by other projects based on the CI framework"....

More specifically..

In "project_x" or "project_y" in my index.php handler I can set my basepath to use the underlying core functionality from the "code_igniter" project ("/src/ci/system/libraries/"), and still access my project-specific libs in say("/src/project_x/system/application/libraries/").

e.g. in a "project_x" controller... say function index() I can do:

$this->load->library('project_x_lib');

...and still reach out to the core CI lib via something like:

$ci =& get_instance();
$ci->load->library('session');

..where Session.php lives in /src/ci/system/lib/ and 'Project_x_lib.php' lives in /src/project_x/system/application/libraries/

..what I *also* need to do is load a library from this 3rd "shared" codebase..

e.g. I need to load a class from /src/cross_project_lib/system/libraries/ (or application/libraries) ..something that is "cross project" but shares common functionality, but not part-of or source-controlled in neither the "project_x" or project_y" or core "ci" projects...

**sure** I could just include(/src/cross_project_lib/bla...), but that would diverge from the CI coding standards, etc, etc...

Is there a way to "append" a path to a "3rd" or 4th or 5th codebase or directory structure when it comes to the Loader Class?

Confused yet? ;o)

The key here is to not muck with the core CI codebase (by simply adding files to the directory structure)... I know I can just do that... but I want to maintain / segregate the (maintained by the community, subject to different release schedules) CI codebase from my 'developed internally, extension of the CI codebase for project-specific functionality' side of things...

Make sense?
#2

[eluser]Unknown[/eluser]
We can scratch this thread - I have found a viable solution! Smile
#3

[eluser]kyleect[/eluser]
Could you please post the solution if possible so other can learn from the thread? Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB