Skip to content

Commit

Permalink
Merge pull request #676 from tighten/jbk/drop-eol-php
Browse files Browse the repository at this point in the history
[2.x] Drop support for EOL versions of PHP and Laravel
  • Loading branch information
bakerkretzmar authored Oct 12, 2023
2 parents 9c6255d + 7a4fba7 commit 57b4d25
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 121 deletions.
22 changes: 15 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@ on:
push:
branches: [main, next, ci]
paths-ignore: ['dist/**', '*.md']
concurrency:
group: ${{ github.ref_name }}
cancel-in-progress: true
jobs:
test:
name: ${{ matrix.os[0] }}, PHP ${{ matrix.php }}, Laravel ${{ matrix.laravel }}, prefer-${{ matrix.dependencies }}
name: ${{ matrix.os[0] }}, PHP ${{ matrix.php }}, Laravel ${{ matrix.laravel }}
runs-on: ${{ matrix.os[1] }}
continue-on-error: ${{ matrix.php == 8.3 }}
strategy:
matrix:
os: [[Ubuntu, ubuntu-latest], [Windows, windows-latest]]
php: [8.1, 8.2]
laravel: [9.*, 10.*]
dependencies: [lowest, highest]
php: [8.1, 8.2, 8.3]
laravel: [9, 10, 11]
exclude:
- php: 8.1
laravel: 11
include:
- php: 8.3
composer: --ignore-platform-req=php+
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
Expand All @@ -24,12 +32,12 @@ jobs:
extensions: fileinfo
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 20
cache: 'npm'
- run: composer require laravel/framework:"${{ matrix.laravel }}.*" --no-update --no-interaction
- uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: ${{ matrix.php == 8.3 && '--ignore-platform-req=php+' || '' }}
composer-options: ${{ matrix.composer }}
- run: vendor/bin/phpunit --testdox --colors=always
- run: npm ci && npm run build
- run: npm run test
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

Ziggy provides a JavaScript `route()` function that works like Laravel's, making it a breeze to use your named Laravel routes in JavaScript.

Ziggy supports all versions of Laravel from `5.4` onward, and all modern browsers.

- [**Installation**](#installation)
- [**Usage**](#usage)
- [`route()` function](#route-function)
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
}
],
"require": {
"php": "~8.1.0",
"php": ">=8.1",
"ext-json": "*",
"laravel/framework": "^9.0"
"laravel/framework": ">=9.0"
},
"require-dev": {
"orchestra/testbench": "^7.0",
"phpunit/phpunit": "^9.0"
"orchestra/testbench": "^7.0 || ^8.0 || ^9.0",
"phpunit/phpunit": "^9.5 || ^10.3"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/BladeRouteGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ private function generateMergeJavascript(Ziggy $ziggy, $nonce)

private function getRouteFunction()
{
return config('ziggy.skip-route-function') ? '' : file_get_contents(__DIR__ . '/../dist/index.js');
return config('ziggy.skip-route-function') ? '' : file_get_contents(__DIR__ . '/../dist/route.umd.js');
}
}
4 changes: 2 additions & 2 deletions src/Output/Types.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Tightenco\Ziggy\Output;
namespace Tighten\Ziggy\Output;

use Illuminate\Support\Arr;
use Stringable;
use Tightenco\Ziggy\Ziggy;
use Tighten\Ziggy\Ziggy;

class Types implements Stringable
{
Expand Down
15 changes: 0 additions & 15 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@

use Closure;
use Orchestra\Testbench\TestCase as OrchestraTestCase;
use PHPUnit\Framework\Constraint\StringContains;
use Tighten\Ziggy\Ziggy;
use Tighten\Ziggy\ZiggyServiceProvider;

class TestCase extends OrchestraTestCase
{
public static function assertStringContainsString(string $needle, string $haystack, string $message = ''): void
{
$constraint = new StringContains($needle, false);

static::assertThat($haystack, $constraint, $message);
}

protected function tearDown(): void
{
Ziggy::clearRoutes();
Expand All @@ -29,13 +21,6 @@ protected function getPackageProviders($app)
return [ZiggyServiceProvider::class];
}

protected function laravelVersion(int $v = null)
{
$version = (int) head(explode('.', app()->version()));

return isset($v) ? $version >= $v : $version;
}

protected function noop(): Closure
{
return function () {
Expand Down
8 changes: 2 additions & 6 deletions tests/Unit/CommandRouteGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,6 @@ public function can_generate_dts_file()
/** @test */
public function can_generate_dts_file_with_scoped_bindings()
{
if (! $this->laravelVersion(7)) {
$this->markTestSkipped('Requires Laravel >=7');
}

app('router')->get('posts', $this->noop())->name('posts.index');
app('router')->get('posts/{post}/comments/{comment:uuid}', PostCommentController::class)->name('postComments.show');
app('router')->post('posts/{post}/comments', PostCommentController::class)->name('postComments.store');
Expand Down Expand Up @@ -197,7 +193,7 @@ public function can_generate_dts_file_without_routes()
Artisan::call('ziggy:generate', ['--types-only' => true]);

$this->assertFileExists(base_path('resources/js/ziggy.d.ts'));
$this->assertFileNotExists(base_path('resources/js/ziggy.js'));
$this->assertFileDoesNotExist(base_path('resources/js/ziggy.js'));
}

/** @test */
Expand All @@ -211,7 +207,7 @@ public function can_derive_dts_file_path_from_given_path()
Artisan::call('ziggy:generate', ['--types-only' => true]);

$this->assertFileExists(base_path('resources/js/custom.d.ts'));
$this->assertFileNotExists(base_path('resources/js/ziggy.d.ts'));
$this->assertFileDoesNotExist(base_path('resources/js/ziggy.d.ts'));
}
}

Expand Down
27 changes: 6 additions & 21 deletions tests/Unit/RouteModelBindingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@ protected function setUp(): void
$router->get('replies/{reply}', function (Reply $reply) {
return '';
})->name('replies');

if ($this->laravelVersion(7)) {
$router->get('blog/{category}/{post:slug}', function (PostCategory $category, Post $post) {
return '';
})->name('posts');
$router->get('blog/{category}/{post:slug}/{tag:slug}', function (PostCategory $category, Post $post, Tag $tag) {
return '';
})->name('posts.tags');
}
$router->get('blog/{category}/{post:slug}', function (PostCategory $category, Post $post) {
return '';
})->name('posts');
$router->get('blog/{category}/{post:slug}/{tag:slug}', function (PostCategory $category, Post $post, Tag $tag) {
return '';
})->name('posts.tags');

$router->getRoutes()->refreshNameLookups();
}
Expand Down Expand Up @@ -128,10 +125,6 @@ public function can_handle_bound_and_unbound_parameters_in_the_same_route()
/** @test */
public function can_handle_multiple_scoped_bindings()
{
if (! $this->laravelVersion(7)) {
$this->markTestSkipped('Requires Laravel >=7');
}

$this->assertSame([
'posts' => [
'uri' => 'blog/{category}/{post}',
Expand All @@ -158,10 +151,6 @@ public function can_handle_multiple_scoped_bindings()
/** @test */
public function can_merge_implicit_and_scoped_bindings()
{
if (! $this->laravelVersion(7)) {
$this->markTestSkipped('Requires Laravel >=7');
}

$this->assertSame([
'users' => [
'uri' => 'users/{user}',
Expand Down Expand Up @@ -245,10 +234,6 @@ public function can_merge_implicit_and_scoped_bindings()
/** @test */
public function can_include_bindings_in_json()
{
if (! $this->laravelVersion(7)) {
$this->markTestSkipped('Requires Laravel >=7');
}

$json = '{"url":"http:\/\/ziggy.dev","port":null,"defaults":{},"routes":{"users":{"uri":"users\/{user}","methods":["GET","HEAD"],"parameters":["user"],"bindings":{"user":"uuid"}},"admins":{"uri":"admins\/{admin}","methods":["GET","HEAD"],"parameters":["admin"],"bindings":{"admin":"uuid"}},"tags":{"uri":"tags\/{tag}","methods":["GET","HEAD"],"parameters":["tag"],"bindings":{"tag":"id"}},"tokens":{"uri":"tokens\/{token}","methods":["GET","HEAD"],"parameters":["token"]},"users.numbers":{"uri":"users\/{user}\/{number}","methods":["GET","HEAD"],"parameters":["user","number"],"bindings":{"user":"uuid"}},"users.store":{"uri":"users","methods":["POST"]},"comments":{"uri":"comments\/{comment}","methods":["GET","HEAD"],"parameters":["comment"],"bindings":{"comment":"uuid"}},"replies":{"uri":"replies\/{reply}","methods":["GET","HEAD"],"parameters":["reply"],"bindings":{"reply":"uuid"}},"posts":{"uri":"blog\/{category}\/{post}","methods":["GET","HEAD"],"parameters":["category","post"],"bindings":{"category":"id","post":"slug"}},"posts.tags":{"uri":"blog\/{category}\/{post}\/{tag}","methods":["GET","HEAD"],"parameters":["category","post","tag"],"bindings":{"category":"id","post":"slug","tag":"slug"}}}}';

$this->assertSame($json, (new Ziggy)->toJson());
Expand Down
Loading

0 comments on commit 57b4d25

Please sign in to comment.