我是Symfony的新手,但不是PHP的新手.我只是无法弄清楚为什么我无法从自定义捆绑包中获得主页路由,但它确实似乎是从控制台输出工作.当我在我的Web浏览器中执行路由时,它将始终/从AppBundle 重新路由路由,即默认的Symfony欢迎页面,即使AppBundle已从AppKernal.php中的registerBundles()函数中删除.我可以确认这一点,因为如果从/ src中删除AppBundle目录,我将收到以下错误日志:
[2016-06-22 19:07:57] request.INFO: Matched route "homepage". {"route_parameters":{"_controller":"AppBundle\\Controller\\DefaultController::indexAction","_route":"homepage"},"request_uri":"http://bvd-v3.dev/"} []
[2016-06-22 19:07:57] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2016-06-22 19:07:57] request.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "Class "AppBundle\Controller\DefaultController" does not exist." at /Users/apple/projects/mentel/bvd-v3/var/cache/prod/classes.php line 2498 {"exception":"[object] (InvalidArgumentException(code: 0): Class \"AppBundle\\Controller\\DefaultController\" does not exist. at /Users/apple/projects/mentel/bvd-v3/var/cache/prod/classes.php:2498)"} []
Run Code Online (Sandbox Code Playgroud)
但是,如果我打电话 php bin/console router:match /
输出是:
+--------------+---------------------------------------------------------+
| Property | Value |
+--------------+---------------------------------------------------------+
| Route Name | homepage |
| Path | / |
| Path …Run Code Online (Sandbox Code Playgroud) 目前,我真的很沮丧,可以借助对Guzzle更有经验的人的帮助。
如果我想要来自API服务器的代码消息响应而不是完整链接响应,则我连接到需要布尔值的API。
以下是原始http客户端(邮递员)访问的两种返回类型之间的区别的示例:
我遇到的问题是,当我使用Guzzle 6发出相同的请求时,我将始终获得完整的链接响应,并且永远无法在要应用的帖子正文中获得布尔值。似乎布尔参数被字符串化为“ true”(这是我的猜测)。
因此,以下两个POST请求产生的结果完全相同:
// define request parameters
$this->req_body = [
'email' => $encrypted_email,
'code' => true
];
// request url
$request_url = $api_endpoint . self::RETURN_TYPE;
// instance of Guzzle Client
$client = $this
->client();
// abstract connection
// XXX: this request needs no headers
$response = $client
->post($request_url, array(
'form_params' => $this->req_body
));
// real data
$data = $response
->getBody()
->getContents();
// send output
$this->response = $data;
Run Code Online (Sandbox Code Playgroud)
如果我尝试将codeform参数注释掉:
// define request parameters …Run Code Online (Sandbox Code Playgroud)