• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best way to share files among different CI projects, i.e. helpers, libraries

#1
I have 3 projects that will each be using a REST API library I customized based on the CI Rest API Library project. It has it's own helpers, models and Libraries. I don't want to have the files spread out in the app folder, some in the helpers directory, the libraries directory, etc.

So I created a folder in third_party and used the same structure as the app folder:

libraries
models
helpers

etc., with my custom code.

If I want to load them however, I am not sure how I would go about doing that. 

Would I just have to do the usual "require_once" approach in the construct of the controller which will require them? Or is there a way to load->helper, for example, and specify the third_party directory? 

I am not sure if codeigniter will automatically find them.
Reply

#2
(12-29-2019, 07:27 PM)deltatangodt Wrote: I have 3 projects that will each be using a REST API library I customized based on the CI Rest API Library project. It has it's own helpers, models and Libraries. I don't want to have the files spread out in the app folder, some in the helpers directory, the libraries directory, etc.

So I created a folder in third_party and used the same structure as the app folder:

libraries
models
helpers

etc., with my custom code.

If I want to load them however, I am not sure how I would go about doing that. 

Would I just have to do the usual "require_once" approach in the construct of the controller which will require them? Or is there a way to load->helper, for example, and specify the third_party directory? 

I am not sure if codeigniter will automatically find them.


Hello,

For Codeigniter 3 you can use hmvc see here for information.
For Codeigniter 4 you can use "namespacing see here for information.

In both ways you can build also a version V1 and V2 off your API ect.
I think it can help you.

Andre
Reply

#3
I have a project that is full functional in http://real.abrkof.com that work exactly how you require
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.