Skip to content

Commit

Permalink
Merge pull request #175 from tighten/mes/php-versions
Browse files Browse the repository at this point in the history
Add supported PHP versions
  • Loading branch information
mattstauffer authored Aug 29, 2023
2 parents 16ecff4 + 296359e commit 75213fb
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 36 deletions.
22 changes: 17 additions & 5 deletions app/Console/Commands/FetchLatestReleaseNumbers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use PHLAK\SemVer\Version;
Expand Down Expand Up @@ -83,18 +84,20 @@ public function handle(): int
{
Log::info('Syncing Laravel Versions');

$manualData = $this->getManualData();

$this->fetchVersionsFromGitHub()
->each(function ($item) {
->each(function ($item) use ($manualData) {
$semver = new Version($item['name']);
$firstReleaseSemver = $semver->major > 5 ? $semver->major . '.0.0' : $semver->major . '.' . $semver->minor . '.0';
$firstRelease = LaravelVersion::where('first_release', $firstReleaseSemver)->first();
$manualMajor = $manualData[$semver->major > 5 ? $semver->major : $semver->major . '.' . $semver->minor];

$versionMeta = [
'changelog' => $item['changelog'],
'order' => LaravelVersion::calculateOrder($semver->major, $semver->minor, $semver->patch),
'released_at' => Carbon::parse($item['released_at'])->format('Y-m-d'),
'ends_bugfixes_at' => $firstRelease?->ends_bugfixes_at,
'ends_securityfixes_at' => $firstRelease?->ends_securityfixes_at,
'ends_bugfixes_at' => $manualMajor->ends_bugfixes_at,
'ends_securityfixes_at' => $manualMajor->ends_securityfixes_at,
'supported_php' => $manualMajor->supported_php,
];

$version = LaravelVersion::withoutGlobalScope('first')
Expand Down Expand Up @@ -192,4 +195,13 @@ private function fetchVersionsFromGitHub()
);
});
}

private function getManualData()
{
$import = json_decode(File::get(base_path('manual-version-info.json')));

return collect($import)->mapWithKeys(function ($item) {
return [$item->release => $item];
});
}
}
1 change: 1 addition & 0 deletions app/Http/Resources/LaravelVersionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function toArray($request): array
'released_at' => $this->released_at,
'ends_bugfixes_at' => $this->ends_bugfixes_at,
'ends_securityfixes_at' => $this->ends_securityfixes_at,
'supported_php' => explode(', ', $this->supported_php),
'status' => $this->status,
$this->mergeWhen($this->specificVersionProvided($request), [
'specific_version' => [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
Schema::table('laravel_versions', function (Blueprint $table) {
$table->string('supported_php')->nullable();
});
}

public function down(): void
{
Schema::table('laravel_versions', function (Blueprint $table) {
$table->dropColumn('supported_php');
});
}
};
134 changes: 134 additions & 0 deletions manual-version-info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
[
{
"release": "10",
"ends_bugfixes_at": "2024-08-07",
"ends_securityfixes_at": "2025-02-07",
"supported_php": "8.1, 8.2, (8.3)"
},
{
"release": "9",
"ends_bugfixes_at": "2023-08-08",
"ends_securityfixes_at": "2024-02-08",
"supported_php": "8.0, 8.1, 8.2, (8.3)"
},
{
"release": "8",
"ends_bugfixes_at": "2022-07-26",
"ends_securityfixes_at": "2023-01-24",
"supported_php": "7.3, 7.4, 8.0"
},
{
"release": "7",
"ends_bugfixes_at": "2020-10-06",
"ends_securityfixes_at": "2021-03-03",
"supported_php": "7.2, 7.3, 7.4, 8.0"
},
{
"release": "6",
"ends_bugfixes_at": "2021-09-07",
"ends_securityfixes_at": "2022-09-06",
"supported_php": "7.2, 7.3, 7.4"
},
{
"release": "5.8",
"ends_bugfixes_at": "2019-08-26",
"ends_securityfixes_at": "2020-02-26",
"supported_php": "7.1, 7.2, 7.3, 7.4?"
},
{
"release": "5.7",
"ends_bugfixes_at": "2019-03-04",
"ends_securityfixes_at": "2019-09-04",
"supported_php": "7.1, 7.2, 7.3, 7.4?"
},
{
"release": "5.6",
"ends_bugfixes_at": "2018-08-07",
"ends_securityfixes_at": "2019-02-07",
"supported_php": "7.1, 7.2, 7.3, 7.4?"
},
{
"release": "5.5",
"ends_bugfixes_at": "2019-08-30",
"ends_securityfixes_at": "2020-08-30",
"supported_php": "7.0, 7.1, 7.2"
},
{
"release": "5.4",
"ends_bugfixes_at": "2017-07-24",
"ends_securityfixes_at": "2018-01-24",
"supported_php": "5.6, 7.0, 7.1"
},
{
"release": "5.3",
"ends_bugfixes_at": "2017-02-23",
"ends_securityfixes_at": "2017-08-23",
"supported_php": "5.6, 7.0"
},
{
"release": "5.2",
"ends_bugfixes_at": "2016-06-21",
"ends_securityfixes_at": "2016-12-12",
"supported_php": "5.5, 5.6, 7.0"
},
{
"release": "5.1",
"ends_bugfixes_at": "2017-06-09",
"ends_securityfixes_at": "2018-06-09",
"supported_php": "5.5, 5.6, 7.0?"
},
{
"release": "5.0",
"ends_bugfixes_at": "2015-08-04",
"ends_securityfixes_at": "2016-02-04",
"supported_php": "5.4, 5.5, 5.6"
},
{
"release": "4.2",
"ends_bugfixes_at": null,
"ends_securityfixes_at": null,
"supported_php": ""
},
{
"release": "4.1",
"ends_bugfixes_at": null,
"ends_securityfixes_at": null,
"supported_php": ""
},
{
"release": "4.0",
"ends_bugfixes_at": null,
"ends_securityfixes_at": null,
"supported_php": ""
},
{
"release": "3.2",
"ends_bugfixes_at": null,
"ends_securityfixes_at": null,
"supported_php": ""
},
{
"release": "3.1",
"ends_bugfixes_at": null,
"ends_securityfixes_at": null,
"supported_php": ""
},
{
"release": "3.0",
"ends_bugfixes_at": null,
"ends_securityfixes_at": null,
"supported_php": ""
},
{
"release": "2.0",
"ends_bugfixes_at": null,
"ends_securityfixes_at": null,
"supported_php": ""
},
{
"release": "1.0",
"ends_bugfixes_at": null,
"ends_securityfixes_at": null,
"supported_php": ""
}
]
12 changes: 9 additions & 3 deletions resources/views/partials/tables/current_table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<table class="min-w-full divide-y divide-gray-200">
<thead>
<tr class="bg-gray-50">
<th scope="col" class="py-3 pl-6 font-medium tracking-wider text-left text-gray-500 uppercase lg:pl-8">
<th scope="col" class="py-3 pl-6 font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('Version') }}
</th>
<th scope="col" class="py-3 pl-6 font-medium tracking-wider text-left text-gray-500 uppercase lg:pl-8">
<th scope="col" class="py-3 pl-6 font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('Release date') }}
</th>
<th scope="col" class="py-3 pl-6 font-medium tracking-wider text-left text-gray-500 uppercase lg:pl-8">
Expand All @@ -18,6 +18,9 @@
<th scope="col" class="py-3 pl-6 font-medium tracking-wider text-left text-gray-500 uppercase lg:pl-8">
{{ __('Security Fixes Until') }}
</th>
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('PHP Versions') }}
</th>
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('Status') }}
</th>
Expand All @@ -34,7 +37,7 @@
}}</a>
</th>
<td class="px-6 py-4 text-sm text-gray-500 whitespace-nowrap">
{{ $version->released_at->gt(now())
{{ $version->released_at->gt(now())
? 'Q' . $version->released_at->quarter . ' ' . $version->released_at->year . ' (' . __('estimated') . ')'
: $version->released_at->translatedFormat(__('DateLongFormat')) }}

Expand All @@ -53,6 +56,9 @@
: $version->ends_securityfixes_at->translatedFormat(__('DateLongFormat')) }}
@endif
</td>
<td class="py-4 pl-6 text-sm text-gray-500 lg:pl-6 whitespace-nowrap">
{{ $version->supported_php }}
</td>
<td scope="col">
<div class="{{ $statusClassMap[$version->status] }}">
<span>{{ $statusTextMap[$version->status] }}</span>
Expand Down
52 changes: 29 additions & 23 deletions resources/views/partials/tables/eol_table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,21 @@
<table class="min-w-full divide-y divide-gray-200">
<thead>
<tr class="bg-gray-50">
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase lg:pl-8">
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('Version') }}
</th>
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase lg:pl-8">
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('Release date') }}
</th>
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase lg:pl-8">
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('Bug Fixes Until') }}
</th>
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase lg:pl-8">
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('Security Fixes Until') }}
</th>
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('PHP Versions') }}
</th>
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('Status') }}
</th>
Expand All @@ -32,41 +35,44 @@
<tbody class="bg-white divide-y divide-gray-200">

@foreach ($inactiveVersions as $version)
<tr>
<th class="px-6 py-4 text-sm font-medium text-left text-gray-900 whitespace-nowrap">
<a href="{{ $version->url }}" class="border-hover">{{ $version->major }}{{
<tr>
<th class="px-6 py-4 text-sm font-medium text-left text-gray-900 whitespace-nowrap">
<a href="{{ $version->url }}" class="border-hover">{{ $version->major }}{{
$version->major < 6
? '.' . $version->minor
: ''
}}</a>
</th>
<td class="px-6 py-4 text-sm text-gray-500 whitespace-nowrap">
{{
</th>
<td class="px-6 py-4 text-sm text-gray-500 whitespace-nowrap">
{{
$version->released_at->translatedFormat(__('DateLongFormat')) }} {{ $version->released_at->gt(now())
? '(' . __('estimated') . ')'
: ''
}}
</td>
<td class="px-6 py-4 text-sm text-gray-500 whitespace-nowrap">
{{
</td>
<td class="px-6 py-4 text-sm text-gray-500 whitespace-nowrap">
{{
$version->ends_bugfixes_at
? $version->ends_bugfixes_at->translatedFormat(__('DateLongFormat'))
: ''
}}
</td>
<td class="px-6 py-4 text-sm text-gray-500 whitespace-nowrap">
{{
</td>
<td class="px-6 py-4 text-sm text-gray-500 whitespace-nowrap">
{{
$version->ends_securityfixes_at
? $version->ends_securityfixes_at->translatedFormat(__('DateLongFormat'))
: ''
}}
</td>
<td scope="col">
<div class="{{ $statusClassMap[$version->status] }}">
<span>{{ $statusTextMap[$version->status] }}</span>
</div>
</td>
</tr>
</td>
<td class="py-4 pl-6 text-sm text-gray-500 lg:pl-6 whitespace-nowrap">
{{ $version->supported_php }}
</td>
<td scope="col">
<div class="{{ $statusClassMap[$version->status] }}">
<span>{{ $statusTextMap[$version->status] }}</span>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
Expand Down
14 changes: 10 additions & 4 deletions resources/views/partials/tables/show_table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase lg:pl-8">
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('Major Version') }}
</th>
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase lg:pl-8">
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('Release date') }}
</th>
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase lg:pl-8">
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('Bug Fixes Until') }}
</th>
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase lg:pl-8">
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('Security Fixes Until') }}
</th>
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase">
{{ __('PHP Versions') }}
</th>
<th scope="col" class="py-3 pl-6 text-xs font-medium tracking-wider text-left text-gray-500 uppercase lg:pl-8">
{{ __('Status') }}
</th>
Expand Down Expand Up @@ -77,6 +80,9 @@
: ''
}}
</td>
<td class="px-6 py-4 text-sm text-gray-500 whitespace-nowrap">
{{ $version->supported_php }}
</td>
<td scope="col">
<div class="{{ $statusClassMap[$version->status] }}">
<span>{{ $statusTextMap[$version->status] }}</span>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/versions/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<div class="mt-6 text-center">
{!! __('A list of currently supported PHP versions can be found here: :link', [
'link' => '<a class="text-blue-600 underline" href="https://www.php.net/supported-versions.php">https://www.php.net/supported-versions.php</a>'
'link' => '<a class="text-blue-600 underline" href="https://phpreleases.com/">https://phpreleases.com/</a>'
]);
!!}
</div>
Expand Down
1 change: 1 addition & 0 deletions tests/Feature/ApiListVersionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ private function getVersionsJsonResponse(Collection $versions): string
$versions = $versions->map(fn ($version) => [
'ends_bugfixes_at' => $version->ends_bugfixes_at,
'ends_securityfixes_at' => $version->ends_securityfixes_at,
'supported_php' => explode(', ', $version->supported_php),
'global' => [
'latest_version' => LaravelVersion::withoutGlobalScope('first')->latest('order')->first()->semver,
],
Expand Down

0 comments on commit 75213fb

Please sign in to comment.