CodeIgniter Forums
sharing library between Multiple Applications with one CodeIgniter Installation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: sharing library between Multiple Applications with one CodeIgniter Installation (/showthread.php?tid=62880)



sharing library between Multiple Applications with one CodeIgniter Installation - kendysond - 09-04-2015

before version 3.0.0/3.0.1 i could share a library between all my "Multiple Applications with one CodeIgniter Installation", by putting the library file in the system/libraries folder, but with this new version update, i get the error

An Error Was Encountered

Non-existent class: CI_Formsclass

ps: formclass is the name of the library

please can anyone help me achieve this since the codeigniter team decided to remove the feature thank you.


RE: sharing library between Multiple Applications with one CodeIgniter Installation - ivantcholakov - 09-04-2015

https://github.com/ivantcholakov/starter-public-edition-4
Put the shared library here: https://github.com/ivantcholakov/starter-public-edition-4/tree/v4.0.65/platform/common/libraries


RE: sharing library between Multiple Applications with one CodeIgniter Installation - kilishan - 09-04-2015

You shouldn't put anything in the `system` folders. Leave that for CodeIgniter otherwise your changes will get overwritten whenever you upgrade the CI core.

Instead, for common libraries, create a new folder, and add that folder as a Package in both of your applications. You can have this path autoloaded by adding it to the autoload.php config file. By default it will load APPPATH/third_party but you can always replace that if you don't use it.

Code:
$autoload['packages'] = array(FCPATH.'common');



RE: sharing library between Multiple Applications with one CodeIgniter Installation - kendysond - 09-04-2015

(09-04-2015, 07:10 AM)kilishan Wrote: You shouldn't put anything in the `system` folders. Leave that for CodeIgniter otherwise your changes will get overwritten whenever you upgrade the CI core.

Instead, for common libraries, create a new folder, and add that folder as a Package in both of your applications. You can have this path autoloaded by adding it to the autoload.php config file. By default it will load APPPATH/third_party but you can always replace that if you don't use it.


Code:
$autoload['packages'] = array(FCPATH.'common');
Thanks for the feedback, i tried it but it didn't work


RE: sharing library between Multiple Applications with one CodeIgniter Installation - kilishan - 09-04-2015

(09-04-2015, 04:52 PM)kendysond Wrote: Thanks for the feedback, i tried it but it didn't work

It's always helpful to provide more details on exactly what you did that didn't work. Otherwise, we don't have any idea how to help you.

I just ran through the process and did the following:
  • Created a new folder called "common" at the same level as the index file and application/system folders
  • Created a new library at "/common/libraries/Tryme.php with a simple die('found it!') in the constructor to ensure the class was found and loaded.
  • Added "FCPATH .'common' to the "config/autoload" setting for packages.
  • Added "$this->load->library('tryme')" to the welcome controller.

When I visited the site, it died with the "Found it!" text on the screen as expected.


RE: sharing library between Multiple Applications with one CodeIgniter Installation - kendysond - 09-19-2015

(09-04-2015, 07:40 PM)kilishan Wrote:
(09-04-2015, 04:52 PM)kendysond Wrote: Thanks for the feedback, i tried it but it didn't work

It's always helpful to provide more details on exactly what you did that didn't work. Otherwise, we don't have any idea how to help you.

I just ran through the process and did the following:

  • Created a new folder called "common" at the same level as the index file and application/system folders
  • Created a new library at "/common/libraries/Tryme.php with a simple die('found it!') in the constructor to ensure the class was found and loaded.
  • Added "FCPATH .'common' to the "config/autoload" setting for packages.
  • Added "$this->load->library('tryme')" to the welcome controller.

When I visited the site, it died with the "Found it!" text on the screen as expected.

OMG!!!!!!! ???? ?????I'm just seeing this now, i just tried and it worked like a charm, i deeply appreciate Sir!!!!!!

i used "substr(BASEPATH,0,-7)" instead of FCPATH though, this means alot Sir, Have a great Day!