• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Separate Client Portal from main app

#1
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
"The Most Important Thing In Life Is Showing Up"
"I Just Had A Bad Day"
"We'll Be Back"
"Further Beyond"
Reply

#2
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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
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
Reply

#4
Separate session ids too.
Reply

#5
(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\
Greetings.
Reply

#6
(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 ?
"The Most Important Thing In Life Is Showing Up"
"I Just Had A Bad Day"
"We'll Be Back"
"Further Beyond"
Reply

#7
(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.
Greetings.
Reply

#8
If you place all the controller class files into the one MY_Controller file then you do not need an autoloader.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#9
(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 ? )
"The Most Important Thing In Life Is Showing Up"
"I Just Had A Bad Day"
"We'll Be Back"
"Further Beyond"
Reply

#10
Maybe like this https://github.com/bcit-ci/codeigniter-w...8626053572
Keep calm.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.