router does not work when I load the website on the server but if it works on my computer what is the problem?

When joining the virtual host route on my computer dev-website.com/admin I have no problems but when I want to go to the web server displays the following message website.com/admin

Dispatcher has detected a cyclic routing stability Causing problems
# 0 [internal function]: Phalcon\Mvc\Dispatcher->_throwDispatchException('Dispatcher has ...', 1)
# 1 [internal function]: Phalcon\dispatcher->dispatch ()
No. 2 /var/www/html/avinka.com/public/index.php(33): Phalcon\Mvc\application-> handle ()
# 3 {main}
#routes.php

$router = new Phalcon\Mvc\Router();

$router->add('/:controller/:action/:params', array(
    'namespace' => 'Project\Controllers',
    'controller' => 1,
    'action' => 2,
    'params' => 3,
));

$router->add('/:controller', array(
    'namespace' => 'Project\Controllers',
    'controller' => 1
));

$router->add('/admin/:controller/:action/:params', array(
    'namespace' => 'Project\Controllers\Admin',
    'controller' => 1,
    'action' => 2,
    'params' => 3,
));

$router->add('/admin/:controller', array(
    'namespace' => 'Project\Controllers\Admin',
    'controller' => 1
));

$router->add('/admin', array(
    'namespace' => 'Project\Controllers\Admin',
    'controller' => 'index'
));

what is the possible problem?

It's seems you added some Session stuff, like Auth. And on your home site you logged-in and all is ok. One a remote server you have a loop on redirecting when checking Auth or Acl



2.3k
edited Jan '15

in sub folder admin on ControllerBase.php file

namespace Project\Controllers\Admin;

use Phalcon\Mvc\Controller;
use Phalcon\Mvc\Dispatcher;
use Project\Auth;
class ControllerBase extends Controller
{

    public function beforeExecuteRoute(Dispatcher $dispatcher)
    {
        $this->view->setMainView('layouts/admin');
        $identity = $this->auth->getIdentity();


        $identity = $this->auth->getIdentity();
        // If there is no identity available the user is redirected to index/index
        if (!is_array($identity)) {
            $this->flash->notice('You don\'t have access to this module: private');
            $this->response->redirect("session/login");
            return false;
        }

    }

    public function afterExecuteRoute()
    {
        $this->view->setViewsDir($this->view->getViewsDir() . 'admin/');
    }

}

I think here I have to make a change, or perhaps in the database table delete sessions_login use the application vokuro

Please give a code of session\login method, it seems like your Session controller extends from ControllerBase



2.3k

this is the code public function loginAction() { $form = new LoginForm();

    try {

        if (!$this->request->isPost()) {

            if ($this->auth->hasRememberMe()) {
                return $this->auth->loginWithRememberMe();
            }
        } else {

            if ($form->isValid($this->request->getPost()) == false) {
                foreach ($form->getMessages() as $message) {
                    $this->flash->error($message);
                }
            } else {

                $this->auth->check(array(
                    'email' => $this->request->getPost('email'),
                    'password' => $this->request->getPost('password'),
                    'remember' => $this->request->getPost('remember')
                ));

                return $this->response->redirect('admin/index');
            }
        }
    } catch (AuthException $e) {
        $this->flash->error($e->getMessage());
    }

    $this->view->form = $form;
}

Is your Session controller extends from ControllerBase ?



2.3k

The session controller is extended ControllerBase.php of the root.

Driver runs from ControllerBase.php session of the root within controllers I have a folder called "admin" and inside I have the ControllerBase.php where is the validation to enter the / admin, on my route this specified.

Need a code-review to solve a problem.

Try to look something like dispatcher->forward, it seems you have a cycled dispatcher-forward calls



2.3k
edited Jan '15

The problem is that the router does not recognize the namespace

$router->add('/admin/index', array( 'namespace' => 'Avinka\Controllers\Admin', 'controller' => 'index' ));

and it did not work.