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 6245329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:29:08+00:00 2026-05-24T12:29:08+00:00

I’m upgrading a dev site to Cake 2.0 Beta and my custom routing appears

  • 0

I’m upgrading a dev site to Cake 2.0 Beta and my custom routing appears to be broken. The previous site routed the url /login to the Employees controller, action:login. This is the code setting up the routes:

Router::connect('/login', array('controller' => 'employees', 'action' => 'login'));
Router::connect('/login/*', array('controller' => 'employees', 'action' => 'login'));

I instead get the standard error when Cake can’t find a controller for a page:

Error: LoginController could not be found.

Meaning it’s not being routed at all; LoginController isn’t supposed to be called nor does it exist. I’ve confirmed that the login function in EmployeesController is never even being started. The page should be routed to the EmployeesController login() function which generates the Employees Login view.

Did I miss a change in how Cake handles routing? Is there anything that might be the issue here?

Update:

I know order can matter with the routes, so here is the exact order of the related router statements in app/config/routes.php:

Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));

CakePlugin::routes();

require CAKE . 'Config' . DS . 'routes.php';

Router::connect('/', array('controller' => 'pages', 'action' => 'home'));

Router::connect('/login', array('controller' => 'employees', 'action' => 'login'));
Router::connect('/login/*', array('controller' => 'employees', 'action' => 'login'));
Router::connect('/logout', array('controller' => 'employees', 'action' => 'logout'));

There are several more routes but they’re all just pretty URLs aren’t aren’t called in this situation.

In addition this is the function from EmployeesController that redirects the user to the actual /login URL. Everything runs fine until this redirect:

    function doLogin() {
    $goto = (isset($this->params['url']['url'])) ? $this->params['url']['url'] : '';
    $goto = $goto = str_replace('/','|',$goto);
    $goto = $goto = str_replace(':','~',$goto);
    if (strpos($goto,'|')===0) $goto = substr($goto,1);
    if ($goto) $goto = '/goto:'.$goto;
    $this->redirect('/login/'.$goto);
    die();
}

The $goto/str_replace() stuff is just to construct a URL to go to after the user has logged in successfully. It’s not being used in this situation, we’re just being redirected to /login/
Do I need to redirect a different way now? This redirect IS going to the right URL, but once there it is NOT being routed, despite the correct router:connect statement.

Update:
The order of the routes in routes.php appears to be part of the issue; I changed my route for /login to be above the require CAKE . 'config' . DS . 'routes.php' as such:

Router::connect('/login', array('controller' => 'employees', 'action' => 'login'));
Router::connect('/login/*', array('controller' => 'employees', 'action' => 'login'));
require CAKE . 'Config' . DS . 'routes.php';

I’ve confirmed that now the ‘login‘ action from EmployeesController.php now executes, so they routing is being done right to that extent.
However I now get the following error:

Notice (8): Undefined index: datasource [CORE\Cake\Model\ConnectionManager.php, line 252]
Errors Missing Datasource Class
Error: Datasource class was not found.

Is this caused because I’m routing before Cake’s default routes? I’m using Cake’s default database plugins (Sqlserver) to connect, did this routing change break the routing to the database plugin? If it’s a different issue I can create a separate question, because if the above fix is unrelated to the missing datasource, the original issue is fixed.

  • 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-24T12:29:10+00:00Added an answer on May 24, 2026 at 12:29 pm

    No, as i commented you before, your routing is ok. check my screencapture. I have Cakephp 2.0 Beta, just testing with your code to route to EmployeesController. Maybe another Code is corrupting the routing sequence, maybe Cakephp 2.0 have cache for routing.

    ScreenShot

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text

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.