Phalcon Micro - 带有空白参数的路由



我有一个nginx + phalcon3.3 + php7服务器和一个带有phalconMicro的脚本,在我正在设置的下一个路由中:

$app->get(
"/{animal}",
function ($animal) {
$REQUEST_URI = $_SERVER[REQUEST_URI];
echo "$REQUEST_URI<br/>";
echo "animal: $animal";
if($animal === ''){
echo '<br/>No animal, :(';
}
}
);

请求 http://localhost:81/cat/dog/bird 我得到:

animals/cat/dog/bird
animal:
No animal, :(

我正在尝试获得:

animals/cat/dog/bird
animal: cat

我的错误是什么,我已经吃了 phalcon micro 教程、phalcon micro api 文档以及 nginx + phalcon 文档。

顺便说一句,有我的nginx规则:

location ~ /animals {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME thePhalconMicroScript.php;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}

你必须像这样定义你的nginx:

location ~ [^/].php(/|$) {
fastcgi_pass  unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index /index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+?.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_param PATH_INFO       $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

https://docs.phalconphp.com/en/3.3/webserver-setup#nginx

最新更新