简体   繁体   中英

Add package path to codeigniter autoload

I have multiple(two) Codeigniter applications in one project. The directory structure looks like that:

applications
--application
--oglasnik

I want to use a helper from application in oglasnik.

$this->load->add_package_path(APPPATH."../application");
$this->load->helper("string_helper");
$this->load->remove_package_path();

This works fine, but i need this helper quite a lot in the application, so is it possible to set a helper from another application in autoload.

Create a relative soft symbolic link in oglasnik/helpers named string_helper.php that points to ../../../application/helpers/string_helper.php . This way you can use the normal load method as PHP will think that file exists in the regular helper path, but it actually is the symbolic link pointing to the original one.

See this on how to create a symbolic link.

(run this in oglasnik/helpers )
Example Command:

ln -s ../../../application/helpers/string_helper.php string_helper.php

To test that link was created correctly, opening the symbolic link string_helper.php created in oglasnik/helpers should open the file string_helper.php located in application/helpers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM