Phalconphp路线不工作

编程入门 行业动态 更新时间:2024-10-07 16:15:50
本文介绍了Phalconphp路线不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是新来的phalconphp,并跟随他们的教程,据我了解,我并不需要创建一个特定的路由组成部分,它应该拿起一个途径,如果它的存在。我显然是大规模错在这里,这意味着它应该很容易指正!但到目前为止,将工作的唯一控制器是我indexController的。

I'm new to phalconphp and following their tutorials, as far as I understand it, I don't need to create a specific routing component and that it should pick up a route if it exists. I could obviously be massively wrong here which means it should be easy to correct me! But so far the only controller that will work is my indexController.

这是我的引导

<?php try { //Register an autoloader $loader = new \Phalcon\Loader(); $loader->registerDirs(array( '../app/controllers/', '../app/models/' ))->register(); //Create a DI $di = new Phalcon\DI\FactoryDefault(); //Setting up the view component $di->set('view', function(){ $view = new \Phalcon\Mvc\View(); $view->setViewsDir('../app/views/'); return $view; }); //Handle the request $application = new \Phalcon\Mvc\Application($di); echo $application->handle()->getContent(); } catch(\Phalcon\Exception $e) { echo "PhalconException: ", $e->getMessage(); }

然后,如果我创造我自己的FooController的

And then if I create my own FooController

<?php class FooController extends \Phalcon\Mvc\Controller { public function indexAction() { echo "FOO"; } public function fooAction(){ echo "FOO"; } }

这些操作都不永远不会被解雇。现在,我居然收到来自服务器的404错误文件。所以,我不知道是否有一个问题,我的.htaccess文件,再次尽管这是从教程直接复制

Neither of these actions will ever get fired. Now I actually receive a 404 error document from the server. So I'm not sure if there's an issue with my .htaccess file, again though this is copied straight from the tutorial

<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] </IfModule>

任何人都可以看到什么明显错在这里?唯一的区别是我设置了为indexController的一个观点。我认为这是这是导致我相信这是更大的问题,与服务器404建立那么也许我的PHP code

Can anyone see anything obviously wrong here? The only difference is I've set up a view for the indexController. I think it's the 404 which is leading me to believe it's more an issue with the server set-up perhaps then my php code

推荐答案

您的.htaccess文件是罚款,不,你不需要任何路由文件,如果你只想使用标准的MVC /控制器/动作类型模式

Your .htaccess file is fine and, no, you don't need any routes file if you just want to use the standard MVC /controller/action type pattern.

您的问题是,您的HTTP服务器没有重新编写正确的URL。我不知道哪个HTTP服务器,你都在用,所以,我不能提供任何细节上固定的HTTP服务器本身。

Your issue is that your http server is not re-writing the URLs properly. I'm not sure which http server you are using, so, I can't provide any specifics on fixing the http server itself.

更多推荐

Phalconphp路线不工作

本文发布于:2023-11-25 21:33:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631427.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路线   工作   Phalconphp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!