我的 xampp/htdocs 目录中有一个名为 phalcon 的简单项目,我将 apache 配置为指向该文件夹,以便我可以在浏览器中转到 phalcon/。

当我尝试打开索引(默认)以外的索引 Controller View 时会出现问题。例如,我在索引 Controller 中有 someAction,在 View /索引中有 some.phtml。
如果我转到phalcon/index/some,我不会从some.phtml中获得文本输出到页面。
这可能是因为它认为我不想打开 IndexController->indexAction 并将一些作为参数传递。

为解决此问题提供的任何帮助将不胜感激。
附言项目骨架是从 https://github.com/phalcon/skeleton-single 复制的。

索引 Controller :

<?php

class IndexController extends ControllerBase
{

  public function indexAction($action = null)
  {

  }
  public function someAction () {
      exit('test');
  }

}

View /索引/index.phtml :
<?php echo $this->getContent(); ?>

View /索引/some.phtml:
Some Action

views/index.phtml
<!DOCTYPE html>
<html>
<head>
  <title>Phalcon PHP Framework</title>
</head>
<body>
  <?php echo $this->getContent(); ?>
</body>
</html>

最佳答案

我不确定我是否完全理解你的问题,但我认为你的 Action 必须与 View 中的文件夹/文件匹配,并且具有相同的名称才能运行。

另外,我看到您在那里扩展了“ControllerBase”,然后在 Controller 文件中是否有一个名为“ControllerBase”的文件,其中包含:

class ControllerBase extends \Phalcon\Mvc\Controller

您可以检查的另一件事是公共(public)文件夹中的 index.php。大多数情况下,发生这些事情是因为DI丢失或输入错误。

关于php - 不能在 Phalcon php 中调用 indexController 的除 indexAction 以外的 Action ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23022841/

10-13 03:17