简体   繁体   English

Phalcon确实改变了看法

[英]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. 发生的是,当我单击链接转到注册页面时,它显示正确的url,这意味着我们应该在注册页面上,但是它显示索引视图而不是注册视图。 Basically when i click on the signup link the only thing that changes in the browser is the url but not the page. 基本上,当我单击注册链接时,浏览器中唯一发生变化的是URL,而不是页面。

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. 确保(在我的情况下为Nginx)您确认已正确设置。

The second thing to look at is the code to handle the request. 要看的第二件事是处理请求的代码。 I have used this: $application = new \\Phalcon\\Mvc\\Application(); 我曾经用过:$ application = new \\ Phalcon \\ Mvc \\ Application(); $application->setDI($di); $应用程序 - > setDI($二);

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 这并不是我想要的,但是由于某种原因,即使我在php.ini中将cgi.fix_pathinfo设置为1,我的PATH_INFO还是为空。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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