Skip to content

Commit 3db47e7

Browse files
authored
Add Symfony Flex recipe to Installation Instructions (#321)
* Add Symfony Flex recipe to Installation Instructions * Changes in the README and update the custom HTTP factory/transport section.
1 parent 2190ea7 commit 3db47e7

File tree

1 file changed

+40
-26
lines changed

1 file changed

+40
-26
lines changed

README.md

+40-26
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,28 @@ Use sentry-symfony for:
2121
- app path
2222
- excluded paths (cache and vendor)
2323

24-
## Installation
25-
26-
### Step 1: Download the Bundle
27-
You can install this bundle using Composer:
28-
24+
## Installation with Symfony Flex (Symfony 4 or newer):
25+
If you're using the [Symfony Flex](https://symfony.com/doc/current/setup/flex.html) Composer plugin, you can install this bundle in a single, easy step:
2926
```bash
30-
composer require sentry/sentry-symfony:^3.0
27+
composer require sentry/sentry-symfony
3128
```
29+
This could show a message similar to this:
30+
```
31+
The recipe for this package comes from the "contrib" repository, which is open to community contributions.
32+
Review the recipe at https://github.com/symfony/recipes-contrib/tree/master/sentry/sentry-symfony/3.0
3233
33-
#### Optional: use custom HTTP factory/transport
34-
*Note: this step is optional*
35-
36-
Since SDK 2.0 uses HTTPlug to remain transport-agnostic, you need to have installed two packages that provides
37-
[`php-http/async-client-implementation`](https://packagist.org/providers/php-http/async-client-implementation)
38-
and [`http-message-implementation`](https://packagist.org/providers/psr/http-message-implementation).
39-
40-
This bundle depends on `sentry/sdk`, which is a metapackage that already solves this need, requiring our suggested HTTP
41-
packages: the Curl client and Guzzle's message factories.
34+
Do you want to execute this recipe?
35+
```
36+
Press `y` and return to allow the installation.
4237

43-
If instead you want to use a different HTTP client or message factory, you'll need to require manually those additional
44-
packages:
38+
## Installation without Symfony Flex:
39+
### Step 1: Download the Bundle
40+
You can install this bundle using Composer:
4541

4642
```bash
47-
composer require sentry/sentry-symfony:^3.0 sentry/sentry:^2.0 php-http/guzzle6-adapter guzzlehttp/psr7
43+
composer require sentry/sentry-symfony:^3.0
4844
```
4945

50-
The `sentry/sentry` package is required directly to override `sentry/sdk`, and the other two packages are up to your choice;
51-
in the current example, we're using both Guzzle's components (client and message factory).
52-
53-
> TODO: Flex recipe
54-
5546
### Step 2: Enable the Bundle
5647

5748
Then, enable the bundle by adding it to the list of registered bundles
@@ -80,10 +71,10 @@ class AppKernel extends Kernel
8071
Note that, unlike before in version 3, the bundle will be enabled in all environments; event reporting, instead, is enabled
8172
only when providing a DSN (see the next step).
8273

83-
### Step 3: Configure the SDK
74+
## Configuration of the SDK
8475

85-
Add your [Sentry DSN](https://docs.sentry.io/quickstart/#configure-the-dsn) value of your project to ``app/config/config_prod.yml``.
86-
Leaving this value empty (or undeclared) in other environments will effectively disable Sentry reporting.
76+
Add your [Sentry DSN](https://docs.sentry.io/quickstart/#configure-the-dsn) value of your project, if you have Symfony 3.4 add it to ``app/config/config_prod.yml`` for Symfony 4 or newer add the value to `config/packages/sentry.yaml`.
77+
Keep in mind that leaving the `dsn` value empty (or undeclared) in other environments will effectively disable Sentry reporting.
8778

8879
```yaml
8980
sentry:
@@ -137,6 +128,29 @@ services:
137128
tags: { name: monolog.processor, handler: sentry }
138129
```
139130

131+
#### Optional: use custom HTTP factory/transport
132+
133+
Since SDK 2.0 uses HTTPlug to remain transport-agnostic, you need to have installed two packages that provides
134+
[`php-http/async-client-implementation`](https://packagist.org/providers/php-http/async-client-implementation)
135+
and [`http-message-implementation`](https://packagist.org/providers/psr/http-message-implementation).
136+
137+
This bundle depends on `sentry/sdk`, which is a metapackage that already solves this need, requiring our suggested HTTP
138+
packages: the Curl client and Guzzle's message factories.
139+
140+
If instead you want to use a different HTTP client or message factory, you can override the ``sentry/sdk`` package adding the following to your ``composer.json`` after the ``require`` section:
141+
```yaml
142+
"replace": {
143+
"sentry/sdk": "*"
144+
}
145+
```
146+
This will prevent the installation of ``sentry/sdk`` package and will allow you to install through Composer the HTTP client or message factory of your choice.
147+
148+
For example for using Guzzle's components:
149+
150+
```bash
151+
composer require php-http/guzzle6-adapter guzzlehttp/psr7
152+
```
153+
140154
## Maintained versions
141155
* 3.x is actively maintained and developed on the master branch, and uses Sentry SDK 2.0;
142156
* 2.x is supported only for fixes; from this version onwards it requires Symfony 3+ and PHP 7.1+;

0 commit comments

Comments
 (0)