Skip to content

Commit 20616b2

Browse files
committed
Updated AirbrakeService to support airbrake/phpbrake v0.8
1 parent 278f37d commit 20616b2

File tree

5 files changed

+28
-57
lines changed

5 files changed

+28
-57
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ composer.phar
5050

5151
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
5252
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
53-
# composer.lock
53+
composer.lock
5454
/nbproject/
5555
/.idea/

LICENSE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
MIT License
22

3-
Copyright (c) 2017 enscope, s.r.o.
4-
53
Permission is hereby granted, free of charge, to any person obtaining a copy
64
of this software and associated documentation files (the "Software"), to deal
75
in the Software without restriction, including without limitation the rights

README.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
# yii2-airbrake
2+
23
Airbrake integration for Yii2, which wraps around official
34
[Airbrake PHP library (airbrake/phpbrake)](https://github.com/airbrake/phpbrake).
45

56
## Installation
7+
68
composer require biller/yii2-airbrake
79

810
## Usage
11+
912
While it is not explicitly required, it is recommended to configure the `AirbrakeService`
10-
as a component in environment (or even common) configuration, so it is easily accessible
11-
from the whole application (using i.e. `Yii::$app->get('airbrakeService')`).
13+
as a component in environment (or even common) configuration, so it is easily accessible from the whole application (
14+
using i.e. `Yii::$app->get('airbrakeService')`).
1215

1316
```php
1417
return [
@@ -43,6 +46,7 @@ return [
4346
],
4447
];
4548
```
49+
4650
*Configuration options marked with asterisk are required, all other options are optional.*
4751

4852
* `rootDirectory`: should be set to your sources root to allow shortening of file paths
@@ -57,19 +61,21 @@ return [
5761
*For additional information about the API, please consult official Airbrake PHP library documentation.*
5862

5963
### AirbrakeFilterFactory
64+
6065
Factory class that can be used to create various filtering rules.
6166

6267
#### `AirbrakeFilterFactory::createParamsFilter(array $params, $replacement = 'FILTERED')`
68+
6369
Method will create filtering callable that filters parameters, specified by
64-
`$params` and replaces it with specified `$replacement`. Example usage is
65-
available above.
70+
`$params` and replaces it with specified `$replacement`. Example usage is available above.
6671

6772
## Console Support
68-
Integration can be added to Yii console, where it currently provides a command
69-
to track deployment (new feature in Airbrake API 4 that allows to mark error
70-
timeline with deployments).
73+
74+
Integration can be added to Yii console, where it currently provides a command to track deployment (new feature in
75+
Airbrake API 4 that allows to mark error timeline with deployments).
7176

7277
### Usage
78+
7379
To use `ConsoleController`, `AirbrakeService` should be configured as component.
7480

7581
import enscope\Yii2\Ext\Airbrake\ConsoleController;
@@ -85,8 +91,8 @@ To use `ConsoleController`, `AirbrakeService` should be configured as component.
8591
],
8692
];
8793

88-
While parameters can be hard-coded in configuration, console controller
89-
supports `inferParameters`, `username`, `revision` and `repository`
94+
While parameters can be hard-coded in configuration, console controller supports `inferParameters`, `username`
95+
, `revision` and `repository`
9096
parameters to be set by arguments on command line.
9197

9298
* `airbrakeService`: name of the component or initialized instance
@@ -96,10 +102,13 @@ parameters to be set by arguments on command line.
96102
* `username`: name of the user tracking deploy (default "system")
97103

98104
## Logging Target
105+
99106
You can configure Yii2 logger to log errors automatically to Airbrake Service.
100107

101108
### Usage
109+
102110
To use `ConsoleController`, `AirbrakeService` should be configured as component.
111+
103112
```php
104113
return [
105114
'components' => [
@@ -114,10 +123,14 @@ return [
114123
],
115124
];
116125
```
117-
The target currently does not expose any other configuration options
118-
other then those exposed by `yii\log\Target`, except the service component:
126+
127+
The target currently does not expose any other configuration options other then those exposed by `yii\log\Target`,
128+
except the service component:
129+
119130
* `airbrakeService`: name of the component or initialized instance
120131

121132
## License
122-
Yii2 Airbrake integration is licensed under [The MIT License (MIT)](https://github.com/enscope/yii2-airbrake/blob/master/LICENSE)
133+
134+
Yii2 Airbrake integration is licensed
135+
under [The MIT License (MIT)](https://github.com/biller/yii2-airbrake/blob/master/LICENSE)
123136
as is the original PHP Airbrake library and follows the versioning of that library.

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
},
1919
"minimum-stability": "stable",
2020
"require": {
21-
"yiisoft/yii2": ">=2.0.5",
21+
"php": "^7.0",
22+
"yiisoft/yii2": "^2.0",
2223
"airbrake/phpbrake": "^0.8"
2324
},
2425
"autoload": {

src/AirbrakeService.php

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Airbrake\ErrorHandler;
66
use Airbrake\Errors\Base;
77
use Airbrake\Exception;
8-
use Airbrake\Http\Factory;
98
use Airbrake\Instance;
109
use Throwable;
1110
use Yii;
@@ -14,11 +13,6 @@
1413

1514
class AirbrakeService extends Component
1615
{
17-
18-
const CLIENT_DEFAULT = 'default';
19-
const CLIENT_GUZZLE = 'guzzle';
20-
const CLIENT_CURL = 'curl';
21-
2216
/** @var bool Enabled flag to allow simpler configuration */
2317
public $enabled = true;
2418

@@ -43,9 +37,6 @@ class AirbrakeService extends Component
4337
/** @var string Service server host */
4438
public $host = 'api.airbrake.io';
4539

46-
/** @var string HTTP client to use */
47-
public $httpClient;
48-
4940
/** @var bool If true, global instance is set on init() */
5041
public $setGlobalInstance = true;
5142

@@ -86,7 +77,6 @@ public function init()
8677
'environment' => $this->environment,
8778
'rootDirectory' => Yii::getAlias($this->rootDirectory),
8879
'host' => $this->host,
89-
'httpClient' => $this->httpClient,
9080
]);
9181

9282
if (is_array($this->filters)) {
@@ -166,36 +156,6 @@ public function sendNotice(array $notice)
166156
return $this->enabled ? $this->_notifier->sendNotice($notice) : true;
167157
}
168158

169-
/**
170-
* Sends deployment tracking request to Airbrake.
171-
* Uses Airbrake client factory internally to adhere to default
172-
* implementation as much as possible.
173-
*
174-
* @param string $revision Revision identifier from source control
175-
* @param string $username Name of the user invoking tracker (default 'system')
176-
* @param string|null $repository Identifier of the repository (optional)
177-
*
178-
* @return bool True, if request was sent successfully
179-
*
180-
* @throws InvalidArgumentException
181-
* @throws Exception
182-
*/
183-
public function trackDeploy($revision, $username = 'system', $repository = null)
184-
{
185-
$client = Factory::createHttpClient($this->httpClient);
186-
$url = sprintf('%s/projects/%s/deploys?key=%s', $this->getAirbrakeApiUrl(), $this->projectId, $this->projectKey);
187-
188-
$result = $client->send($url, json_encode([
189-
'environment' => $this->environment,
190-
'username' => $username,
191-
'repository' => $repository,
192-
'revision' => $revision,
193-
'version' => $this->appVersion,
194-
]));
195-
196-
return $result !== false;
197-
}
198-
199159
/**
200160
* Creates and returns API endpoint for specified version
201161
* of Airbrake API with hostname specified in parameter.
@@ -245,5 +205,4 @@ public function getNotifier()
245205
{
246206
return $this->_notifier;
247207
}
248-
249208
}

0 commit comments

Comments
 (0)