Skip to content

Commit e4dfa9f

Browse files
authored
Drop Laravel Lumen support (#579)
1 parent b9bb0e3 commit e4dfa9f

File tree

8 files changed

+13
-175
lines changed

8 files changed

+13
-175
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Drop support for Laravel Lumen (#579)
6+
57
## 2.14.0
68

79
- Fix not listening to queue events because `QueueManager` is registered as `queue` in the container and not by it's class name (#568)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ try {
7878

7979
## Laravel Version Compatibility
8080

81+
- Laravel Lumen is supported until `2.14.x`
8182
- Laravel `<= 4.2.x` is supported until `0.8.x`
8283
- Laravel `<= 5.7.x` on PHP `<= 7.0` is supported until `0.11.x`
8384
- Laravel `>= 5.x.x` on PHP `>= 7.1` is supported in all versions

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
"symfony/psr-http-message-bridge": "^1.0 | ^2.0",
2929
"nyholm/psr7": "^1.0"
3030
},
31+
"conflict": {
32+
"laravel/lumen-framework": "*"
33+
},
3134
"autoload": {
3235
"psr-0": {
3336
"Sentry\\Laravel\\": "src/"

src/Sentry/Laravel/Integration.php

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -167,68 +167,6 @@ public static function extractNameAndSourceForRoute(Route $route): array
167167
return [$routeName, $source];
168168
}
169169

170-
/**
171-
* Extract the readable name for a Lumen route.
172-
*
173-
* @param array $routeData The array of route data
174-
* @param string $path The path of the request
175-
*
176-
* @return string
177-
*
178-
* @internal This helper is used in various places to extra meaninful info from a Lumen route data.
179-
* @deprecated This will be removed in version 3.0, use `extractNameAndSourceForLumenRoute` instead.
180-
*/
181-
public static function extractNameForLumenRoute(array $routeData, string $path): string
182-
{
183-
return self::extractNameAndSourceForLumenRoute($routeData, $path)[0];
184-
}
185-
186-
/**
187-
* Extract the readable name for a Lumen route and the transaction source for where that route name came from.
188-
*
189-
* @param array $routeData The array of route data
190-
* @param string $path The path of the request
191-
*
192-
* @return array{0: string, 1: \Sentry\Tracing\TransactionSource}
193-
*
194-
* @internal This helper is used in various places to extra meaninful info from a Lumen route data.
195-
*/
196-
public static function extractNameAndSourceForLumenRoute(array $routeData, string $path): array
197-
{
198-
$source = null;
199-
$routeName = null;
200-
201-
$route = $routeData[1] ?? [];
202-
203-
// some.action (route name/alias)
204-
if (!empty($route['as'])) {
205-
$source = TransactionSource::component();
206-
$routeName = self::extractNameForNamedRoute($route['as']);
207-
}
208-
209-
// Some\Controller@someAction (controller action)
210-
if (empty($routeName) && !empty($route['uses'])) {
211-
$source = TransactionSource::component();
212-
$routeName = self::extractNameForActionRoute($route['uses']);
213-
}
214-
215-
// /some/{action} // Fallback to the route uri (with parameter placeholders)
216-
if (empty($routeName) || $routeName === 'Closure') {
217-
$routeUri = array_reduce(
218-
array_keys($routeData[2]),
219-
static function ($carry, $key) use ($routeData) {
220-
return str_replace($routeData[2][$key], "{{$key}}", $carry);
221-
},
222-
$path
223-
);
224-
225-
$source = TransactionSource::url();
226-
$routeName = '/' . ltrim($routeUri, '/');
227-
}
228-
229-
return [$routeName, $source];
230-
}
231-
232170
/**
233171
* Take a route name and return it only if it's a usable route name.
234172
*

src/Sentry/Laravel/ServiceProvider.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Illuminate\Foundation\Application as Laravel;
77
use Illuminate\Foundation\Http\Kernel as HttpKernel;
88
use Illuminate\Log\LogManager;
9-
use Laravel\Lumen\Application as Lumen;
109
use RuntimeException;
1110
use Sentry\ClientBuilder;
1211
use Sentry\ClientBuilderInterface;
@@ -48,10 +47,7 @@ public function boot(): void
4847
if ($this->hasDsnSet()) {
4948
$this->bindEvents();
5049

51-
if ($this->app instanceof Lumen) {
52-
$this->app->middleware(SetRequestMiddleware::class);
53-
$this->app->middleware(SetRequestIpMiddleware::class);
54-
} elseif ($this->app->bound(HttpKernelInterface::class)) {
50+
if ($this->app->bound(HttpKernelInterface::class)) {
5551
/** @var \Illuminate\Foundation\Http\Kernel $httpKernel */
5652
$httpKernel = $this->app->make(HttpKernelInterface::class);
5753

@@ -78,10 +74,6 @@ public function boot(): void
7874
*/
7975
public function register(): void
8076
{
81-
if ($this->app instanceof Lumen) {
82-
$this->app->configure(static::$abstract);
83-
}
84-
8577
$this->mergeConfigFrom(__DIR__ . '/../../../config/sentry.php', static::$abstract);
8678

8779
$this->configureAndRegisterClient();

src/Sentry/Laravel/Tracing/Middleware.php

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ public function terminate($request, $response): void
9191
* @param float|null $timestamp The unix timestamp of the booted event, default to `microtime(true)` if not `null`.
9292
*
9393
* @return void
94-
* @internal This method should only be invoked right after the application has finished "booting":
95-
* For Laravel this is from the application `booted` callback.
96-
* For Lumen this is right before returning from the `bootstrap/app.php` file.
94+
*
95+
* @internal This method should only be invoked right after the application has finished "booting".
9796
*/
9897
public function setBootedTimestamp(?float $timestamp = null): void
9998
{
@@ -190,18 +189,6 @@ private function hydrateRequestData(Request $request): void
190189
'action' => $route->getActionName(),
191190
'method' => $request->getMethod(),
192191
]);
193-
} elseif (is_array($route) && count($route) === 3) {
194-
[$transactionName, $transactionSource] = Integration::extractNameAndSourceForLumenRoute($route, $request->path());
195-
196-
$this->updateTransactionNameIfDefault($transactionName, $transactionSource);
197-
198-
$action = $route[1] ?? [];
199-
200-
$this->transaction->setData([
201-
'name' => $action['as'] ?? null,
202-
'action' => $action['uses'] ?? 'Closure',
203-
'method' => $request->getMethod(),
204-
]);
205192
}
206193

207194
$this->updateTransactionNameIfDefault('/' . ltrim($request->path(), '/'), TransactionSource::url());

src/Sentry/Laravel/Tracing/ServiceProvider.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
use Illuminate\Contracts\View\Engine;
77
use Illuminate\Contracts\View\View;
88
use Illuminate\Foundation\Http\Kernel as HttpKernel;
9-
use Illuminate\Queue\QueueManager;
109
use Illuminate\View\Engines\EngineResolver;
1110
use Illuminate\View\Factory as ViewFactory;
1211
use InvalidArgumentException;
13-
use Laravel\Lumen\Application as Lumen;
1412
use Sentry\Laravel\BaseServiceProvider;
1513
use Sentry\Serializer\RepresentationSerializer;
1614

@@ -29,9 +27,7 @@ public function boot(): void
2927

3028
$this->bindViewEngine($tracingConfig);
3129

32-
if ($this->app instanceof Lumen) {
33-
$this->app->middleware(Middleware::class);
34-
} elseif ($this->app->bound(HttpKernelInterface::class)) {
30+
if ($this->app->bound(HttpKernelInterface::class)) {
3531
/** @var \Illuminate\Foundation\Http\Kernel $httpKernel */
3632
$httpKernel = $this->app->make(HttpKernelInterface::class);
3733

@@ -55,11 +51,9 @@ public function register(): void
5551
return new BacktraceHelper($options, new RepresentationSerializer($options));
5652
});
5753

58-
if (!$this->app instanceof Lumen) {
59-
$this->app->booted(function () {
60-
$this->app->make(Middleware::class)->setBootedTimestamp();
61-
});
62-
}
54+
$this->app->booted(function () {
55+
$this->app->make(Middleware::class)->setBootedTimestamp();
56+
});
6357
}
6458

6559
private function bindEvents(array $tracingConfig): void

test/Sentry/IntegrationTest.php

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -162,83 +162,4 @@ public function testExtractingNameForRouteWithStrippedBaseNamespaceFromAction():
162162

163163
Integration::setControllersBaseNamespace(null);
164164
}
165-
166-
public function testExtractingNameForLumenRouteWithName(): void
167-
{
168-
$route = [0, ['as' => $routeName = 'foo-bar'], []];
169-
170-
$this->assertSame($routeName, Integration::extractNameForLumenRoute($route, '/some-route'));
171-
}
172-
173-
public function testExtractingNameForLumenRouteWithAction(): void
174-
{
175-
$route = [0, ['uses' => $controller = 'SomeController@someAction'], []];
176-
177-
$this->assertSame($controller, Integration::extractNameForLumenRoute($route, '/some-route'));
178-
}
179-
180-
public function testExtractingNameForLumenRouteWithoutName(): void
181-
{
182-
$url = '/some-route';
183-
184-
$this->assertSame($url, Integration::extractNameForLumenRoute([0, [], []], $url));
185-
}
186-
187-
public function testExtractingNameForLumenRouteWithParamInUrl(): void
188-
{
189-
$route = [1, [], ['param1' => 'foo']];
190-
191-
$url = '/foo/bar/baz';
192-
193-
$this->assertSame('/{param1}/bar/baz', Integration::extractNameForLumenRoute($route, $url));
194-
}
195-
196-
public function testExtractingNameForLumenRouteWithParamsInUrl(): void
197-
{
198-
$route = [1, [], ['param1' => 'foo', 'param2' => 'bar']];
199-
200-
$url = '/foo/bar/baz';
201-
202-
$this->assertSame('/{param1}/{param2}/baz', Integration::extractNameForLumenRoute($route, $url));
203-
}
204-
205-
public function testExtractingNameForLumenRouteWithActionAndName(): void
206-
{
207-
$route = [0, [
208-
'as' => $routeName = 'foo-bar',
209-
'uses' => 'SomeController@someAction',
210-
], []];
211-
212-
$this->assertSame($routeName, Integration::extractNameForLumenRoute($route, '/some-route'));
213-
}
214-
215-
public function testExtractingNameForLumenRouteWithAutoGeneratedName(): void
216-
{
217-
// We fake a generated name here, Laravel generates them each starting with `generated::`
218-
$route = [0, ['as' => 'generated::KoAePbpBofo01ey4'], []];
219-
220-
$url = '/some-route';
221-
222-
$this->assertSame($url, Integration::extractNameForLumenRoute($route, $url));
223-
}
224-
225-
public function testExtractingNameForLumenRouteWithIncompleteGroupName(): void
226-
{
227-
$route = [0, ['as' => 'group-name.'], []];
228-
229-
$url = '/some-route';
230-
231-
$this->assertSame($url, Integration::extractNameForLumenRoute($route, $url));
232-
}
233-
234-
public function testExtractingNameForLumenRouteWithStrippedBaseNamespaceFromAction(): void
235-
{
236-
Integration::setControllersBaseNamespace('BaseNamespace');
237-
238-
$route = [0, ['uses' => 'BaseNamespace\\SomeController@someAction'], []];
239-
240-
$this->assertSame('SomeController@someAction', Integration::extractNameForLumenRoute($route, '/some-route'));
241-
242-
Integration::setControllersBaseNamespace(null);
243-
}
244165
}

0 commit comments

Comments
 (0)