简体   繁体   中英

Phalcon does change views

<?php
class  IndexController extends \Phalcon\Mvc\Controller {
    public function indexAction(){

    }
}
?>
<?php
class SignupController extends \Phalcon\Mvc\Controller {
    public function indexAction(){

    }
}
?>
<?php 
    echo "<h1>Hello!</h1>"; 
    echo Phalcon\Tag::linkTo( "signup", "Sign Up Here!");

?>
<?php use Phalcon\Tag; ?>

<h2>Sign up using this form</h2>
<?php echo Tag::form( "signup/register" ); ?>

    <p>
        <label for="name">Name</label>
        <?php echo Tag::textfield( "name" ); ?>
    </p>
    <p>
        <label for="email">E-Mail</label>
        <?php Tag::textfield( "email" ); ?>
    </p>
    <p>
        <?php echo Tag::submitButton( "Register" ); ?>
    </p>
</form>

I was following a tutorial on phalcon framework here but it can't get it to work. I have created the controllers for the index page and the signup page. I also created the views for the index controller and the view for the signup controller.

What happens is that when I click on the link to go to the signup page it shows the url correct which means we should be on the signup page but it shows the index view not the signup view. Basically when i click on the signup link the only thing that changes in the browser is the url but not the page.

anyone know what is going on here?

Ok,

I got this working in the end.

Make sure that (in my case Nginx) you confirm that it has been set up correctly.

The second thing to look at is the code to handle the request. I have used this: $application = new \\Phalcon\\Mvc\\Application(); $application->setDI($di);

if (!empty($_SERVER['REQUEST_URI'])) {
    $pathInfo = $_SERVER['REQUEST_URI'];
} else {
    $pathInfo = '/';
}
echo $application->handle($pathInfo)->getContent();

This isn't exactly what I wanted, but for some reason my PATH_INFO was coming out as empty, even when I have set cgi.fix_pathinfo to 1 in the php.ini

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM