Yii Framework Forum: Separation of admin controllers from public controllers - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Separation of admin controllers from public controllers Handy little technique Rate Topic: ***-- 1 Votes

#21 User is offline   yiimann 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 102
  • Joined: 19-December 09

Posted 13 February 2012 - 07:51 AM

admin module is the best method. Although all routes are mixed up with front ones.
0

#22 User is offline   Seth Ballinger 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 23-January 12

Posted 13 March 2012 - 09:28 AM

Thanks.. Jonah for provide admin directory structure..
0

#23 User is offline   Gusarov 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 16-March 12

  Posted 04 May 2013 - 12:58 PM

How do you create URLs with frontend urlManager rules in backend controllers?

This post has been edited by jacmoe: 04 May 2013 - 01:09 PM
Reason for edit: removed quote

0

#24 User is offline   Chris Backhouse 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 04-August 11
  • Location:France

Posted 16 August 2013 - 09:43 AM

It's a while since anyone has come up with other methods of separating Admin from Public functions so here's my two pennies worth ...

I've just started using a method based on using the URLManager and I find it gives a complete logical separation but with a physical integration, ie: ALL your files remain in one application space.

We start with a structure like this:-
        frontend
           index.php
           assets/
           themes/
        protected/
                config/
                        frontend.php
                        backend.php
                components/
                controllers/
                models/
                views/
        backend/
                index.php
                assets/
                themes/


And then we use the URL manager to block access to admin functions in the frontend.


     'urlManager'=>array(
                    'urlFormat'=>'path',
                    'showScriptName' => false,
                    'rules'=>array(
                        ''=>'post/view',
                        '<model:.*?>/<action:.*?>'=>'site/error',
                        '...'
                  )
               ),



And then I also quite like to obscure the admin functions in the backend using something like this ..
(ps: I know that security through obscurity is not a solution on its own, but it doesn't hurt as an extra layer) .


     'mySecretAdmin/<model:.*?>'=>'<model>/admin',
     '<model:.*?>/admin'=>'site/error'



As a subnote, if my frontend is relatively simple, I use specific rules in the URL manager and exclude anything else, for example; in a blog environment the only actions allowable in the frontend have to do with displaying posts and categories, plus maybe one or two other functions ...


      'search'=>'post/search',
      'posts/<tag:.*?>'=>'post/index',
      'enquiries'=>'site/enquiry',
      ...
      // Lastly, anything else can go to the post controller view action and let it try and sort it out ....
      'post/<action:\w+><id:\d+>' =>'post/view',



I like this way, as to me, it separates the physical organisation from the logical, which is handled by the URL manager, and this seems the right place to do that...

Of course, another advantage, is that we also share other aspects of the main config files, like database access, system parameters and other component/extension configurations.


       'db'=>require(dirname(__FILE__).'/db.php'),



Plus these can also share upload or system wide asset directories by placing them in the application root ...
        frontend
           index.php
           assets/
           themes/
        protected/
                config/
                        frontend.php
                        backend.php
                        db-config.php
                        other-component-configs.php,
                        params.php
                components/
                controllers/
                models/
                views/
        backend/
                index.php
                assets/
                themes/
        uploads/
                media/
                documents/
                ...
        system-assets/
                etc...


0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users