CodeIgniter Forums
Separate Client Portal from main app - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Separate Client Portal from main app (/showthread.php?tid=63590)



Separate Client Portal from main app - Sentro - 11-17-2015

Hello,

I have an application running and about to create a client portal.
Database is the same. What would be the best way to separate the client's portal from the main app??

Split the controllers into folders, one for the "admins" and one for the clients ?

What would be my best option ( security based also ) ?

I've seen people splitting the session also into arrays ( admin,client ) but that would mean a lot of changes for the current
code. I guess i can always use different session variables to check for stuff??

Any help or guidance would be appreciated.

Thank you


RE: Separate Client Portal from main app - InsiteFX - 11-17-2015

I split my controllers into two folders admin and then use the main folder for the clients

./application/controllers - Client controllers
./application/controllers/admin - Admin controllers

I also do the same for the views.


RE: Separate Client Portal from main app - cartalot - 11-17-2015

Quote:What would be my best option ( security based also ) ?

with the disclaimer that i understand some people would consider this too much but...
separate application folders that are one level above the server root
separate admin html folder for logging in

PHP Code:
admin_application/public_html/admin/index.php 

otherwise the default for *any* possible routes is the public client side, which points to the client application folder

PHP Code:
client_application/public_html/index.php 

that way your public client routes are always kept completely separate from admin. otherwise you run the risk of exposing controllers and methods on the public server that should only be for admins. another advantage is that every controller in the admin application requires the user to be logged in. so you aren't constantly having to check - is this an admin or a client?

both can point to the same system folder
PHP Code:
system302/public_html

one advantage of this is you can build and 'break' things in the admin application folder
and then push them to the client application when they are ready for production


RE: Separate Client Portal from main app - ivantcholakov - 11-17-2015

Separate session ids too.


RE: Separate Client Portal from main app - rtorralba - 11-17-2015

(11-17-2015, 03:25 AM)Sentro Wrote: Hello,

I have an application running and about to create a client portal.
Database is the same. What would be the best way to separate the client's portal from the main app??

Split the controllers into folders, one for the "admins" and one for the clients ?

What would be my best option ( security based also ) ?

I've seen people splitting the session also into arrays ( admin,client ) but that would mean a lot of changes for the current
code. I guess i can always use different session variables to check for stuff??

Any help or guidance would be appreciated.

Thank you

Hi,

I think you can make two folders in controllers for backend and frontend and the same at views, and share the models. In addition to this at MY_Controller php file you can add Backend_Controller for extend all backend controllers from it and where you must to check authorization, and put all functions that you need in backend controllers. You can use MY_Controller for frontend controllers.

- core
  - MY_Controller.php
    - class MY_Controller
    - class Backend_Controller
- controllers\
  - backend\
  - frontend\
- models\
- views\
  - backend\
  - frontend\


RE: Separate Client Portal from main app - Sentro - 11-18-2015

(11-17-2015, 04:46 PM)rtorralba Wrote: Hi,

I think you can make two folders in controllers for backend and frontend and the same at views, and share the models. In addition to this at MY_Controller php file you can add Backend_Controller for extend all backend controllers from it and where you must to check authorization, and put all functions that you need in backend controllers. You can use MY_Controller for frontend controllers.

- core
  - MY_Controller.php
    - class MY_Controller
    - class Backend_Controller
- controllers\
  - backend\
  - frontend\
- models\
- views\
  - backend\
  - frontend\

Hello,

I think i'm heading towards this direction. I did a quick lookup and from what i understand i should go with something like the below

My_controller.php
PHP Code:
<?php

class MY_Controller extends CI_Controller
{
  function 
__construct()
  {
    
parent::__construct();
  }
}

class 
Admin_Controller extends MY_Controller
{
  function 
__construct()
  {
    
parent::__construct();
  }
}

class 
Public_Controller extends MY_Controller
{
  function 
__construct()
  {
    
parent::__construct();
  }


So basically extend all the admin controlelrs to Admin_controller and all the public ones to the Public_controller.

I suppose something like that would work ?


RE: Separate Client Portal from main app - rtorralba - 11-18-2015

(11-18-2015, 09:21 AM)Sentro Wrote:
(11-17-2015, 04:46 PM)rtorralba Wrote: Hi,

I think you can make two folders in controllers for backend and frontend and the same at views, and share the models. In addition to this at MY_Controller php file you can add Backend_Controller for extend all backend controllers from it and where you must to check authorization, and put all functions that you need in backend controllers. You can use MY_Controller for frontend controllers.

- core
  - MY_Controller.php
    - class MY_Controller
    - class Backend_Controller
- controllers\
  - backend\
  - frontend\
- models\
- views\
  - backend\
  - frontend\

Hello,

I think i'm heading towards this direction. I did a quick lookup and from what i understand i should go with something like the below

My_controller.php
PHP Code:
<?php

class MY_Controller extends CI_Controller
{
 
 function __construct()
 
 {
 
   parent::__construct();
 
 }
}

class 
Admin_Controller extends MY_Controller
{
 
 function __construct()
 
 {
 
   parent::__construct();
 
 }
}

class 
Public_Controller extends MY_Controller
{
 
 function __construct()
 
 {
 
   parent::__construct();
 
 }


So basically extend all the admin controlelrs to Admin_controller and all the public ones to the Public_controller.

I suppose something like that would work ?

Yes, this works perfectly.


RE: Separate Client Portal from main app - InsiteFX - 11-18-2015

If you place all the controller class files into the one MY_Controller file then you do not need an autoloader.


RE: Separate Client Portal from main app - Sentro - 11-19-2015

(11-18-2015, 01:10 PM)InsiteFX Wrote: If you place all the controller class files into the one MY_Controller file then you do not need an autoloader.

What do you mean ??

Like move every single controller class into the MY_Controller class? ( Leaving me with just 1 controller file ? )


RE: Separate Client Portal from main app - arma7x - 11-19-2015

Maybe like this https://github.com/bcit-ci/codeigniter-website/blob/master/application/core/MY_Controller.php?_e_pi_=7%2CPAGE_ID10%2C8626053572