1. Recently learn yaf to see the manual said default routing, after a series of installation, enter the URL to show Hello World! I am Stranger
this is normal!
2. But I create a new public function testAction
method in the Index.php
file under controlers
. Routing access http://sitename/Index/Index/test
, always accesses the contents of the indexAction
method!
3. Ask for God"s guidance! (also: if I want to classify the controller, for example, the directory is controllers/son/son.php
, the controller in this file inherits the controllers/father.php
directory format, how should I set the route?)
4. The table of contents and various configurations are attached below!
< hr > < H2 > Nginx configuration < / H2 > location / {
try_files $uri $uri/ /index.php;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
-sharp
-sharp if (!-e $request_filename) {
-sharp rewrite ^/(.*) /index.php/$1 last;
-sharp }
}
< H2 > Index Controller < / H2 >
<?php
/**
* @name IndexController
* @author root
* @desc
* @see http://www.php.net/manual/en/class.yaf-controller-abstract.php
*/
class IndexController extends Yaf_Controller_Abstract {
/**
*
* YafYaf_Request_Abstract::getParam()Action
* , http://yourhost/demo/index/index/index/name/root ,
*/
public function indexAction($name = "Stranger") {
//1. fetch query
$get = $this->getRequest()->getQuery("get", "default value");
//2. fetch model
$model = new SampleModel();
//3. assign
$this->getView()->assign("content", $model->selectSample());
$this->getView()->assign("name", $name);
//4. render by Yaf, FALSE, YafRender
return TRUE;
}
public function testAction()
{
echo "this is a test of router";
}
}
ask all bosses to answer questions and questions!