Skip to content

Commit

Permalink
Drop Lumen
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Jan 18, 2025
1 parent 7fa4283 commit 9e20117
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 146 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
run: COMPOSER=composer.lowest.json composer update --prefer-stable


- name: Execute tests (Laravel/Lumen)
- name: Execute tests (Laravel)
run: composer test-ci
if: ${{ matrix.deps == 'highest' }}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

> [v4 is out now](https://scribe.knuckles.wtf/blog/laravel-v4)! Featuring subgroups, easier sorting, and an automated upgrade command.
Scribe helps you generate API documentation for humans from your Laravel/Lumen codebase. See a live example at [demo.scribe.knuckles.wtf](https://demo.scribe.knuckles.wtf).
Scribe helps you generate API documentation for humans from your Laravel codebase. See a live example at [demo.scribe.knuckles.wtf](https://demo.scribe.knuckles.wtf).

## Features
- Useful output:
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"brianium/paratest": "^6.0",
"dms/phpunit-arraysubset-asserts": "^0.4",
"laravel/legacy-factories": "^1.3.0",
"laravel/lumen-framework": "^8.0|^9.0|^10.0",
"league/fractal": "^0.20",
"nikic/fast-route": "^1.3",
"orchestra/testbench": "^6.0|^7.0|^8.0",
Expand Down
1 change: 0 additions & 1 deletion composer.lowest.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"brianium/paratest": "^6.0",
"dms/phpunit-arraysubset-asserts": "^0.2.0",
"laravel/legacy-factories": "^1.3.0",
"laravel/lumen-framework": "^8.0",
"league/fractal": "^0.19.0",
"nikic/fast-route": "^1.3",
"orchestra/testbench": "^6.0|^7.0",
Expand Down
1 change: 0 additions & 1 deletion src/Config/Defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public static function urlParametersStrategies(): StrategyListWrapper
{
return new StrategyListWrapper([
Strategies\UrlParameters\GetFromLaravelAPI::class,
Strategies\UrlParameters\GetFromLumenAPI::class,
Strategies\UrlParameters\GetFromUrlParamAttribute::class,
Strategies\UrlParameters\GetFromUrlParamTag::class,
]);
Expand Down
23 changes: 6 additions & 17 deletions src/Extracting/Strategies/Responses/ResponseCalls.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,26 +249,15 @@ private function addBodyParameters(Request $request, array $body): void
*/
protected function makeApiCall(Request $request, Route $route)
{
return $this->callLaravelOrLumenRoute($request);
return $this->callLaravelRoute($request);
}

protected function callLaravelOrLumenRoute(Request $request): \Symfony\Component\HttpFoundation\Response
protected function callLaravelRoute(Request $request): \Symfony\Component\HttpFoundation\Response
{
// Confirm we're running in Laravel, not Lumen
if (app()->bound(Kernel::class)) {
/** @var \Illuminate\Foundation\Http\Kernel $kernel */
$kernel = app(Kernel::class);
$response = $kernel->handle($request);
$kernel->terminate($request, $response);
} else {
// Handle the request using the Lumen application.
/** @var \Laravel\Lumen\Application $app */
$app = app();
$app->bind('request', function () use ($request) {
return $request;
});
$response = $app->handle($request);
}
/** @var \Illuminate\Foundation\Http\Kernel $kernel */
$kernel = app(Kernel::class);
$response = $kernel->handle($request);
$kernel->terminate($request, $response);

return $response;
}
Expand Down
4 changes: 0 additions & 4 deletions src/Extracting/Strategies/UrlParameters/GetFromLaravelAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ class GetFromLaravelAPI extends Strategy

public function __invoke(ExtractedEndpointData $endpointData, array $routeRules = []): ?array
{
if (Utils::isLumen()) {
return (new GetFromLumenAPI($this->config))($endpointData, $routeRules);
};

$parameters = [];

$path = $endpointData->uri;
Expand Down
59 changes: 0 additions & 59 deletions src/Extracting/Strategies/UrlParameters/GetFromLumenAPI.php

This file was deleted.

23 changes: 0 additions & 23 deletions src/Matching/LumenRouteAdapter.php

This file was deleted.

4 changes: 0 additions & 4 deletions src/Matching/RouteMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ private function getRoutesToBeDocumented(array $routeRules): array
$includes = $routeRule['include'] ?? [];

foreach ($allRoutes as $route) {
if (is_array($route)) {
$route = new LumenRouteAdapter($route);
}

if ($this->shouldExcludeRoute($route, $routeRule)) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ScribeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function bootRoutes()
Str::endsWith(config('scribe.type', 'static'), 'laravel') &&
config('scribe.laravel.add_routes', false)
) {
$routesPath = Utils::isLumen() ? __DIR__ . '/../routes/lumen.php' : __DIR__ . '/../routes/laravel.php';
$routesPath = __DIR__ . '/../routes/laravel.php';
$this->loadRoutesFrom($routesPath);
}
}
Expand Down
33 changes: 0 additions & 33 deletions src/Tools/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,6 @@ public static function replaceUrlParameterPlaceholdersWithValues(string $uri, ar
return $uri;
}

if (self::isLumen()) {
$boundUri = '';
$possibilities = (new Std)->parse($uri);
// See https://github.com/nikic/FastRoute#overriding-the-route-parser-and-dispatcher
$possibilityWithAllSegmentsPresent = end($possibilities);
foreach ($possibilityWithAllSegmentsPresent as $part) {
if (!is_array($part)) {
// It's just a path segment, not a URL parameter'
$boundUri .= $part;
continue;
}

$name = $part[0];
$boundUri .= $urlParameters[$name];
}

return $boundUri;
}

foreach ($urlParameters as $parameterName => $example) {
$uri = preg_replace('#\{' . $parameterName . '\??}#', $example, $uri);
}
Expand Down Expand Up @@ -330,20 +311,6 @@ public static function getModelFactory(string $modelName, array $states = [], ar
return $factory;
}

public static function isLumen(): bool
{
// See https://github.com/laravel/lumen-framework/blob/99330e6ca2198e228f5894cf84d843c2a539a250/src/Application.php#L163
$app = app();
if ($app
&& is_callable([$app, 'version'])
&& Str::startsWith($app->version(), 'Lumen')
) {
return true;
}

return false;
}

/**
* Filter a list of docblock tags to those matching the specified ones (case-insensitive).
*
Expand Down

0 comments on commit 9e20117

Please sign in to comment.