![]() |
I have multiple applications running on a single installation of CI. These apps share the same database.
Project Structure /app1 app public /app2 app public /vendor but i want these applications to have a shared model. A Model that can be accessed in app1 and app2 so i dont have to repeat the same model. How do i achieve this if possible?
Create new folder "/shared" on level "/vendor"
Create new files models as shared/BigModel.php, class BigModel with another namespace Shared\BigModel Edit autoload config https://codeigniter.com/user_guide/conce...figuration added in array "Shared => ./shared"
This is what i have tried
created a shared folder in the rootpath shared \Models \OrderModel.php \Libraries ... The contents of OrderModel.php PHP Code: <?php PHP Code: But it is still not working.
I finally got this to work.
What I did was to create a SHARED_PATH constant in Common.php PHP Code: $d = explode(DIRECTORY_SEPARATOR,ROOTPATH); Then use the SHARED_PATH in my Config/Autoload.php PHP Code: public $psr4 = [ Then in the my Controller I simply use the shared model PHP Code: use Shared\Models\OrderModel; OR PHP Code: $orderModel = new \Shared\Models\OrderModel(); Hope this helps someone.
Your just creating a Module.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |