Welcome Guest, Not a member yet? Register   Sign In
Shared Models between multiple applications
#4

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);
$d[count($d) -2] = "shared";

define('SHARED_PATH' implode(DIRECTORY_SEPARATOR$d)); 

Then use the SHARED_PATH in my Config/Autoload.php

PHP Code:
public $psr4 = [
        APP_NAMESPACE => APPPATH// For custom app namespace
        'Config'      => APPPATH 'Config',
        'Shared' =>  SHARED_PATH
]; 

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


Messages In This Thread
RE: Shared Models between multiple applications - by vimkaf - 09-26-2022, 02:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB