I have a simple project in my xampp/htdocs directory called phalcon and I have apache configured to point to that folder so that I can go to phalcon/ in my browser.
The problem occurs when I try to open an index controller view other than index(default).
For instance I have someAction in Index controller and in views/index I have some.phtml.
If I go to phalcon/index/some I don't get the text from some.phtml outputed to the page.
It's probably because it thinks as if I wan't to open IndexController->indexAction and pass some as a parameter.
Would be grateful on any help provided to resolve this.
P.S. the project skeleton was copied from https://github.com/phalcon/skeleton-single.
Index controller:
<?php
class IndexController extends ControllerBase
{
public function indexAction($action = null)
{
}
public function someAction () {
exit('test');
}
}
views/index/index.phtml :
<?php echo $this->getContent(); ?>
views/index/some.phtml:
Some Action
views/index.phtml
<!DOCTYPE html>
<html>
<head>
<title>Phalcon PHP Framework</title>
</head>
<body>
<?php echo $this->getContent(); ?>
</body>
</html>
Try using custom routing.
This can be done as follows if you are using the skeleton project but the concept is the same for any other application.
create the file app/config/routes.php
In the index.php after loading services.php
is what you're looking for.
I am not sure if I understand your question completely but I think your Action must match the folder/file in view with the same name for it to function.
Also, I see you have extends 'ControllerBase' there then do you have a file called 'ControllerBase' in the controllers file with:
Another thing you can check would be the index.php in your public folder. Most of the time these stuff happens because the DI is missing or with a wrong input.
I think, that you should check your .htaccess file for following rule:
This will enable all other controller actions, not only index. To check that the problem is in this rule you can by access your controller method via url /index.php?_url=/index/some - if it will be loaded, change your .htaccess like in example below
Not sure if that's expected behaviour, but in some scenarios actions from
IndexController
should be requested in Capital case likeIndex/some/
whenindex/some/
would return not found response.