CodeIgniter Forums
Working with 2 applications - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10)
+--- Thread: Working with 2 applications (/showthread.php?tid=63952)



Working with 2 applications - lama - 12-27-2015

Hello,

I'm trying to redevelop my ecommerce with CI3 but I was already blocked with my two applications folder Undecided

I have this folders :
  • applications/frontend/
  • applications/backend/

What I set :

index.php (root)
PHP Code:
$application_folder 'applications/frontend'

applications/frontend/index.php
PHP Code:
$application_folder '../frontend';
$system_path '../system'

applications/frontend/config/config.php
PHP Code:
$config['base_url'] = 'http://localhost/eshop/frontend/'

applications/backend/index.php
PHP Code:
$application_folder '../backend';
$system_path '../system'

applications/backend/config/config.php
PHP Code:
$config['base_url'] = 'http://localhost/eshop/backend/'


Using REQUEST_URI and no index_page blank, all .htaccess are set like this :
PHP Code:
RewriteEngine On
RewriteCond 
%{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteRule 
^(.*)$ index.php/$[L

I'm well redirected on the frontend default controller when I go to localhost/eshop but when I type localhost/eshop/backend I have the 404 default error page.

Any idea ?

Thanks Smile


RE: Working with 2 applications - wolfgang1983 - 12-28-2015

I would look into HMVC https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc

You might be best to create a second application folder called backend
  • backend
  • backend > application
  • backend > application > all folders that belong in app
  • backend > index.php
On that backend index.php just then make one change
 
Code:
$system_path = '../system';

  • backend
  • frontend
  • frontend > all folders that belong in app
  • index.php <-- for front end
  • system folder
On the main index.php you can rename application folder to frontend.

PHP Code:
$application_folder 'frontend'



RE: Working with 2 applications - lama - 01-06-2016

I don't understand... Why this is so complicated to get two applications ?

I followed the user guide : https://ellislab.com/codeigniter/user-guide/general/managing_apps.html but there isn't instructions about htaccess...


RE: Working with 2 applications - wolfgang1983 - 01-06-2016

(01-06-2016, 01:40 PM)lama Wrote: I don't understand... Why this is so complicated to get two applications ?

I followed the user guide : https://ellislab.com/codeigniter/user-guide/general/managing_apps.html but there isn't instructions about htaccess...

Use HMVC


RE: Working with 2 applications - lama - 01-14-2016

I can't rewrite all my project in HMVC there is too much controllers, views and model. I only want to migrate my 2 applications folder of CI2 to CI3...


RE: Working with 2 applications - waptik - 01-18-2016

Instead of giving yourself a hard time,why not just do it simple as this?
One single app with multiple areas.
application/controllers/backend -> all backend controllers go in here.
application/views/backend -> all backend views go in here.
application/controllers -> all frontend controllers go in here.
application/views/frontend -> all frontend views gn in here.
Then in your application/core/MY_Controller.php , create two classes extending to CI_Controller: frontend(disable debug and anything you don't want users to see), backend(enable debug). Then back to your controllers: in application/controllers/{file}.php -> class {file} extends frontend{} , application/controllers/backend/{file}.php -> class {file} extends backend{}.
Now you get http://localhost/eshop and http://localhost/eshop/backend working.