Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6376971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:48:40+00:00 2026-05-25T01:48:40+00:00

I have an application that is essentially working until I tried to implement an

  • 0

I have an application that is essentially working until I tried to implement an Auth module for logins and registrations.

My application directory structure is basically:

application
-- classes
  -- controller
     -- admin
        (admin area)
     -- block
        (blocks to display within pages)
     -- page
        (default pages)

By default I want to have URL’s such as http://www.testsite.com/test which would access the Controller_Page_Test class. Or to explicitly call admin or block pages http://www.testsite.com/admin/test which would access the Controller_Admin_Test class. To further complicate matters it also needs to handle optional actions and id’s.

I said at the top that this is basically working correctly – until I’ve tried to add in the Auth module. The Auth module calls http://www.testsite.com/user/login but instead of accessing the module’s path via the default, it looks in the page directory.

To overcome this I placed a higher level route but now this has become my default page handler. Explicit calls still get through.

My routes currently look like this:

Route::set('user', '(<controller>(/<action>(/<id>)))', array('controller' => 'user|admin_user'))
    ->defaults(array(
        'controller' => 'user',
        'action'     => 'index',
        'id'         => NULL,
    ));

Route::set('with_dir', '<directory>/<controller>(/<action>(/<id>))', array('directory' => 'block|admin'))
    ->defaults(array(
        'directory'  => 'page',
        'controller' => 'home',
        'action'     => 'index',
    ));

Route::set('just_id', '<controller>(/<id>)', array('id' => '\d+'))
    ->defaults(array(
        'directory'  => 'page',
        'controller' => 'home',
        'action'     => 'index',
    ));

Route::set('auto_dir', '<controller>(/<action>(/<id>))', array('id' => '\d+'))
    ->defaults(array(
        'directory'  => 'page',
        'controller' => 'home',
        'action'     => 'index',
    ));


Route::set('default', '(<controller>(/<action>(/<id>)))')
    ->defaults(array(
        'controller' => 'prototype',
        'action'     => 'index',
    ));

Can this be cleaned up any better? And how do I get this module to only kick in when I need it to?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:48:41+00:00Added an answer on May 25, 2026 at 1:48 am

    Yes, it can be cleaned better. Kohana developers encourage people using this framework to add as much routes as needed. You can even specify them for each action which will enable you to change URLs in the future (eg. instead of /user/login you may wish to have /signin), if you use proper methods to generate links etc. (eg. Route::url() helper).

    Now, saying that, here is the other way to specify the user route:

    Route::set('user', '<controller>(/<action>(/<id>))', array('controller' => '(user|admin_user)'))
        ->defaults(array(
            'controller' => 'user',
            'action'     => 'index',
        ));
    

    Which will match only the requests, where the first part of the URI is given and is equal either to user or admin_user. Previously the controller part was optional, thus was also matching calls to / URI.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on a WPF Application that is essentially a WYSIWYG editor,
In my application I have groups which are essentially just tags that can be
I have a php application ( http://github.com/tchalvak/ninjawars ), essentially a php-based webgame that I
I am working on a 64-bit .Net Windows Service application that essentially loads up
I have this ajax web application I am developing that essentially calls the google
I am working on a browser-based application that is essentially a Digital Audio Workstation.
I have some classes that all implement the same Java interface, which essentially allows
I have application that makes different queries with different results so the caching in
I have application that is connecting to the DB and if I enter incorrect
I have application that is up more than 3 days. I can see in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.