current position:Home>YAF CLI and HTTP access modes

YAF CLI and HTTP access modes

2022-04-29 10:22:42Legendary fat man

  Please note that Yaf edition , test 3.2.5 Version in cli In mode Yaf_Request_Simple Can't set $params

//php yaf.php test/test/test aaa bbb    #aaa,bbb Is the parameter 


$application = new Yaf_Application( APPLICATION_PATH . "/conf/application.ini");

if(php_sapi_name()=="cli"){
    // load cli Of bootstrap Configure the content 
    $application->bootstrap();

    $uri_r = explode('/',$argv[1]);
    if($uri_r[2]){
    }elseif($uri_r[1]){
        array_unshift($uri_r,'index');
    }else{
        exit('uri error!');
    }
    list($module,$controller,$action) = $uri_r;
    $params = array_slice($argv,2);

    // Modification request 
    $Request = new Yaf_Request_Simple('CLI',$module,$controller,$action,$params);
    // start-up 
    $application->getDispatcher()->dispatch($Request);
}else{
    $application->bootstrap()->run();
}

Use in calling methods $this->getRequest()->getParams() To obtain parameters

copyright notice
author[Legendary fat man],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204290903530387.html

Random recommended