【发布时间】:2017-01-25 21:43:33
【问题描述】:
在我的 Symfony 3 应用程序中,我使用服务从 rest api 获取数据。
在此服务中,我正在注入“会话”和一个字符串,代表我的 rest api 的基本 url。
public function __construct(Session $session, $magentoRestUrl)
{
$this->session = $session;
$this->client = new \GuzzleHttp\Client([
'base_uri' => $magentoRestUrl, // http://domain.com/rest/V1/
'timeout' => 2.0,
]);
$this->cache = new ApcuAdapter();
$this->groupedIngredients = [];
}
到目前为止,一切都在我的本地计算机上按预期运行。但是现在,在使用尚不存在的$magentoRestUrl 的部署过程中,运行composer install --no-dev 时出现此错误:
...
Writing lock file
Generating autoload files
[GuzzleHttp\Exception\ConnectException]
cURL error 6: Could not resolve host: domain.com (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
Build step 'Execute shell' marked build as failure
Finished: FAILURE
我的问题是:为什么composer install 触发guzzle 来解决$magentoRestUrl?是不是因为在服务类的构造函数中?
这是我的 composer.json:
{
"name": "alex/symfony",
"license": "proprietary",
"type": "project",
"autoload": {
"psr-4": {
"": "src/"
},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"require": {
"php": ">=5.5.9",
"symfony/symfony": "3.1.*",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"symfony/swiftmailer-bundle": "^2.3",
"symfony/monolog-bundle": "^2.8",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"symfony/assetic-bundle": "^2.8",
"leafo/scssphp": "^0.6.3",
"guzzlehttp/guzzle": "^6.2"
},
"require-dev": {
"sensio/generator-bundle": "^3.0",
"symfony/phpunit-bridge": "^3.0"
},
"scripts": {
"post-install-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"post-update-cmd": [
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative"
}
【问题讨论】:
标签: php composer-php symfony guzzle