Welcome Guest, Not a member yet? Register   Sign In
sharing library between Multiple Applications with one CodeIgniter Installation
#1

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.
Reply
#2

(This post was last modified: 09-04-2015, 06:49 AM by ivantcholakov.)

https://github.com/ivantcholakov/starter...-edition-4
Put the shared library here: https://github.com/ivantcholakov/starter.../libraries
Reply
#3

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');
Reply
#4

(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
Reply
#5

(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.
Reply
#6

(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!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB