简体   繁体   中英

Integrating/ Migrating two CodeIgniter applications.

I have two applications developed in CodeIgniter, both are working on separate server, ie

www.CI_App_1.com

and

www.CI_App_2.com

Now I want to integrate CI_App_2 into CI_App_1 application, so after that I'm able to call default_controller of CI_App_2 from one of link from CI_App_1 .

My folder structure :

htdocs :
    -application_1
        -application

            -application_2
                -application
                    -config
                        -autoload.php
                        -config.php
                        -routes.php
                    -controllers
                        -app_2_controller.php
                    -helpers
                    -libraries
                    -models
                        -app_2_model.php
                    -views
                        -app_2_view.php
                -system
                -.htaccess
                -index.php

            -config
                -autoload.php
                -config.php
                -routes.php
            -controllers
                -app_1_controller.php
            -helpers
            -libraries
            -models
                -app_1_model.php
            -views
                -app_1_view.php
        -system
        -.htaccess
        -index.php

I want to access CI_App_2 after user is logedin from CI_App_1 . After authenticating process user is able access my CI_App_2 only, If user try to access it without authenticating, got an error message :

Access forbidden

I referred following links :

Call Controller method of CodeIgniter outside Application directory

CodeIgniter: Load controller within controller

How to load a controller from another controller in codeigniter?

Codeigniter : calling a method of one controller from other

http://www.techsirius.com/2013/01/load-controller-within-another.html

https://www.quora.com/Can-I-call-a-controller-function-that-resides-in-another-controller-in-CodeIgniter

http://www.devnetwork.net/viewtopic.php?f=72&t=131353

how to set up two codeigniter applications running on same server

https://www.codeigniter.com/user_guide/general/managing_apps.html

But in above links they said that it should be done using HMVC module structure, but not any one mention that both controller files are from same application or different. I want to access default_controller from second application into first application.

Is it possible ?

Any kind of help is appreciated. Thanks in advance. Hope you got my question.

Following function set on application_1 default_controller may be its work.

public function _remap($method) {
    $userdata = $this->session->userdata('user');
    if (!empty($userdata)) {
        modules::run('application_2/controller/default_controller');
    }
}

Well, Its best that instead of merging these. you need to shift

app2/controllers  => app1/controllers/app2
app2/views  => app1/views/app2

In this way, you can access app2 inside the app1 with some addition of routes.

I must recommend that don't shift all code of app2 in app1 as it is.

It will not good.

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