You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: example/symfony64/README.md
+36-17Lines changed: 36 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -2,17 +2,47 @@
2
2
3
3
This example shows how to integrate BugSnag with Symfony 6. Full instructions on how to set BugSnag up with Symfony can be found in [the official BugSnag documentation](https://docs.bugsnag.com/platforms/php/symfony/).
4
4
5
+
## Using Docker
5
6
6
-
## Installing dependencies
7
+
This example comes with a `Dockerfile` you can use to run the project.
8
+
Please first build the image:
9
+
10
+
```shell
11
+
docker build -t bugsnag-symfony6 .
12
+
```
13
+
14
+
Then run the container:
15
+
16
+
```shell
17
+
docker run -it --rm -p 8000:8000 bugsnag-symfony6
18
+
```
19
+
20
+
You can then access the application at [http://localhost:8000](http://localhost:8000).
21
+
22
+
## Manual installation
7
23
8
24
1. Install composer, following the instructions provided in the [composer documentation](http://getcomposer.org/doc/01-basic-usage.md)
9
25
10
-
2. Install BugSnag using composer
26
+
2. Install dependencies using composer
11
27
12
28
```shell
13
29
composer install
14
30
```
15
31
32
+
### Running the example
33
+
34
+
To run the example:
35
+
36
+
```shell
37
+
symfony server:start
38
+
```
39
+
40
+
Or for the command example:
41
+
42
+
```shell
43
+
php bin/console app:crash
44
+
```
45
+
16
46
## Configuring BugSnag
17
47
18
48
There are two ways of configuring your BugSnag client.
@@ -27,13 +57,14 @@ bugsnag:
27
57
28
58
2. Use environment variables. In this example you can set the `BUGSNAG_API_KEY` environment variable to your api key. This can also be setin the applications `.env` file:
29
59
30
-
```
60
+
```env
31
61
BUGSNAG_API_KEY=YOUR_API_KEY_HERE
32
62
```
33
63
34
64
More information about configuring BugSnag can be found in [the configuration section of the BugSnag documentation](https://docs.bugsnag.com/platforms/php/symfony/configuration-options/).
35
65
36
66
In Symfony 6 the BugSnag bundle should be automatically registered in the `config/bundles.php` file:
67
+
37
68
```php
38
69
return [
39
70
// ...
@@ -48,13 +79,15 @@ BugSnag will now be set up and ready to notify of any exceptions.
48
79
In order to use BugSnag in any of your classes you will need to require it via dependency injection.
49
80
50
81
In your services.yaml file, bind the Bugsnag\Client class to the @bugsnag service:
82
+
51
83
```yaml
52
84
services:
53
85
# resolve "Bugsnag\Client" to the BugSnag service
54
86
Bugsnag\Client: '@bugsnag'
55
87
```
56
88
57
89
Any of your classes requiring BugSnag can use the type Bugsnag\Client to access it:
90
+
58
91
```php
59
92
private $bugsnag;
60
93
@@ -65,17 +98,3 @@ public function __construct(\Bugsnag\Client $bugsnag)
65
98
```
66
99
67
100
Which allows BugSnag to be used within the class as you would any other property.
0 commit comments