Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit 3a5b5ca

Browse files
author
Emil Andersson
committed
Intercept and customize error from Guzzle
When guzzle is initalized it tried to find a suitable handler to use. If no handler can be found (for example curl) an exception is thrown. With this change we try to find the handler before creating the client so we can pass the handler to the client manually. Doing this, we are able to customize the error message to make it (potentially) less confusing for the users who might have no idea what guzzle is.
1 parent 91e8814 commit 3a5b5ca

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM debian:jessie
2+
VOLUME .:/root/shared
3+
WORKDIR /root/shared
4+
RUN apt-get update && apt-get install -y php5-cli
5+
6+
ENTRYPOINT /bin/bash

src/Symfony/Installer/DownloadCommand.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use GuzzleHttp\Client;
2020
use GuzzleHttp\Exception\ClientException;
2121
use GuzzleHttp\Event\ProgressEvent;
22+
use GuzzleHttp\Utils;
2223
use Symfony\Component\Console\Command\Command;
2324
use Symfony\Component\Console\Helper\ProgressBar;
2425
use Symfony\Component\Console\Input\InputInterface;
@@ -221,7 +222,15 @@ protected function getGuzzleClient()
221222
$defaults['debug'] = true;
222223
}
223224

224-
return new Client(array('defaults' => $defaults));
225+
try {
226+
$handler = Utils::getDefaultHandler();
227+
} catch (\RuntimeException $e) {
228+
throw new \RuntimeException(
229+
'The Symfony installer requires the php-curl extension or the allow_url_fopen ini setting.'
230+
);
231+
}
232+
233+
return new Client(array('defaults' => $defaults, 'handler' => $handler));
225234
}
226235

227236
/**

0 commit comments

Comments
 (0)