Skip to content

Commit 88e8f01

Browse files
authored
Add support for Laravel 11 (#81)
* Add Laravel 11 dependency * Remove/replace broken links * Tweak package versions * Attempt to support PHPUnit v10 and v8 simultaneously * Drop support of PHPUnit v8 Dropping support of PHPUnit v8 means dropping support of PHP 7.2 which means dropping support of Laravel v6 and v7 * Update workflow * Update tests and upgrade phpunit.xml * Update upgrade guide * Attempt to use newer GH actions * Configure Codecov * Formatting * Remove unneeded test case IDE Helper-related issue was patched in v2.9.1, which only supported Laravel 7+. Since we dropped older Laravel versions, we can remove this. @see barryvdh/laravel-ide-helper#627 * Improve phrasing * Whoops * Rearrange
1 parent b1e766f commit 88e8f01

File tree

10 files changed

+71
-93
lines changed

10 files changed

+71
-93
lines changed

.github/workflows/tests.yml

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,32 @@ jobs:
1313
phpunit:
1414
strategy:
1515
matrix:
16-
php: [ 8.2, 8.1, 8.0, 7.4, 7.3, 7.2 ]
17-
laravel: [ 10.*, 9.*, 8.*, 7.*, 6.* ]
16+
php: [ 8.2, 8.1, 8.0, 7.4, 7.3 ]
17+
laravel: [ 11.*, 10.*, 9.*, 8.* ]
1818
os: [ ubuntu-latest, windows-latest ]
1919

2020
# Unsupported combinations
2121
exclude:
22+
- laravel: 11.*
23+
php: 8.1
24+
- laravel: 11.*
25+
php: 8.0
26+
- laravel: 11.*
27+
php: 7.4
28+
- laravel: 11.*
29+
php: 7.3
30+
2231
- laravel: 10.*
2332
php: 8.0
2433
- laravel: 10.*
2534
php: 7.4
2635
- laravel: 10.*
2736
php: 7.3
28-
- laravel: 10.*
29-
php: 7.2
3037

3138
- laravel: 9.*
3239
php: 7.4
3340
- laravel: 9.*
3441
php: 7.3
35-
- laravel: 9.*
36-
php: 7.2
37-
38-
- laravel: 8.*
39-
php: 7.2
40-
41-
- laravel: 7.*
42-
php: 8.2
43-
- laravel: 7.*
44-
php: 8.1
45-
- laravel: 7.*
46-
php: 8.0
47-
48-
- laravel: 6.*
49-
php: 8.2
50-
- laravel: 6.*
51-
php: 8.1
52-
- laravel: 6.*
53-
php: 8.0
5442

5543
# Continue running through matrix even if one combination fails
5644
fail-fast: false
@@ -61,7 +49,7 @@ jobs:
6149

6250
steps:
6351
- name: Check out code
64-
uses: actions/checkout@v3
52+
uses: actions/checkout@v4
6553

6654
- name: Setup PHP
6755
uses: shivammathur/setup-php@v2
@@ -81,6 +69,7 @@ jobs:
8169
run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml
8270

8371
- name: Report coverage to Codecov
84-
uses: codecov/codecov-action@v3
72+
uses: codecov/codecov-action@v4
8573
with:
74+
token: ${{ secrets.CODECOV_TOKEN }}
8675
file: build/logs/clover.xml

README.md

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
A simple Laravel-style way to create breadcrumbs.
1313

14-
This project is the [official fork](https://newsroom.diglactic.com/laravel-breadcrumbs/) of the fantastically original
15-
[Laravel Breadcrumbs by Dave James Miller](https://github.com/davejamesmiller/laravel-breadcrumbs) and wouldn't have
16-
been possible without
17-
[a bunch of awesome day-one contributors](https://github.com/davejamesmiller/laravel-breadcrumbs/graphs/contributors).
14+
This project is the official fork of the fantastically
15+
original [Laravel Breadcrumbs by Dave James Miller](https://github.com/davejamesmiller/laravel-breadcrumbs) and wouldn't
16+
have been possible
17+
without [a bunch of awesome day-one contributors](https://github.com/davejamesmiller/laravel-breadcrumbs/graphs/contributors).
1818
Thanks, all!
1919

2020

@@ -39,9 +39,10 @@ Compatibility Chart
3939

4040
| Laravel | Laravel Breadcrumbs |
4141
|---------|---------------------|
42-
| 10.x | 8.x |
43-
| 9.x | 8.x |
44-
| 8.x | 8.x |
42+
| 11.x | 9.x |
43+
| 10.x | 9.x |
44+
| 9.x | 9.x |
45+
| 8.x | 9.x |
4546
| 7.x | 8.x |
4647
| 6.x | 8.x |
4748

@@ -117,7 +118,7 @@ The possible values are:
117118
- `breadcrumbs::bootstrap4`[Bootstrap 4](https://getbootstrap.com/docs/4.0/components/breadcrumb/)
118119
- `breadcrumbs::bulma`[Bulma](https://bulma.io/documentation/components/breadcrumb/)
119120
- `breadcrumbs::foundation6`[Foundation 6](https://get.foundation/sites/docs/breadcrumbs.html)
120-
- `breadcrumbs::json-ld`[JSON-LD Structured Data](https://developers.google.com/search/docs/data-types/breadcrumbs)
121+
- `breadcrumbs::json-ld`[JSON-LD Structured Data](https://developers.google.com/search/docs/appearance/structured-data/breadcrumb)
121122
- `breadcrumbs::materialize`[Materialize](https://materializecss.com/breadcrumbs.html)
122123
- `breadcrumbs::tailwind`[Tailwind CSS](https://tailwindcss.com/)
123124
- `breadcrumbs::uikit`[UIkit](https://getuikit.com/docs/breadcrumb)
@@ -141,8 +142,8 @@ parameters:
141142
{{ Breadcrumbs::render('category', $category) }}
142143
```
143144

144-
See the [Outputting Breadcrumbs](#outputting-breadcrumbs) section for other output options, and see
145-
[Route-Bound Breadcrumbs](#route-bound-breadcrumbs) for a way to link breadcrumb names to route names automatically.
145+
See the [Outputting Breadcrumbs](#outputting-breadcrumbs) section for other output options, and
146+
see [Route-Bound Breadcrumbs](#route-bound-breadcrumbs) for a way to link breadcrumb names to route names automatically.
146147

147148

148149
Defining Breadcrumbs
@@ -236,8 +237,9 @@ Breadcrumbs::for('post', function (BreadcrumbTrail $trail, Post $post) {
236237
});
237238
```
238239

239-
The `$post` object (probably an Eloquent [Model](https://laravel.com/api/10.x/Illuminate/Database/Eloquent/Model.html),
240-
but could be anything) would be passed in from the view:
240+
The `$post` object (probably an
241+
Eloquent [Model](https://laravel.com/api/master/Illuminate/Database/Eloquent/Model.html), but could be anything) would
242+
be passed in from the view:
241243

242244
```blade
243245
{{ Breadcrumbs::render('post', $post) }}
@@ -348,7 +350,7 @@ you to make edits directly.
348350

349351
#### View data
350352

351-
The view will receive a [Collection](https://laravel.com/api/10.x/Illuminate/Support/Collection.html)
353+
The view will receive a [Collection](https://laravel.com/api/master/Illuminate/Support/Collection.html)
352354
called `$breadcrumbs`.
353355

354356
Each breadcrumb is an [object](https://www.php.net/manual/en/language.types.object.php) with the following keys:
@@ -399,7 +401,8 @@ Or with a parameter:
399401
Structured Data
400402
---------------
401403

402-
To render breadcrumbs as JSON-LD [structured data](https://developers.google.com/search/docs/data-types/breadcrumbs)
404+
To render breadcrumbs as
405+
JSON-LD [structured data](httpshttps://developers.google.com/search/docs/appearance/structured-data/breadcrumb)
403406
(usually for SEO reasons), use `Breadcrumbs::view()` to render the `breadcrumbs::json-ld` template in addition to the
404407
normal one. For example:
405408

@@ -460,7 +463,7 @@ Route::name('home')->get('/', 'HomeController@index');
460463
Route::name('post')->get('/post/{id}', 'PostController@show');
461464
```
462465

463-
For more details, see [Named Routes](https://laravel.com/docs/10.x/routing#named-routes) in the Laravel documentation.
466+
For more details, see [Named Routes](https://laravel.com/docs/routing#named-routes) in the Laravel documentation.
464467

465468
### Name your breadcrumbs to match
466469

@@ -485,8 +488,8 @@ Breadcrumbs::for('post', function (BreadcrumbTrail $trail, Post $post) {
485488
});
486489
```
487490

488-
To add breadcrumbs to a [custom 404 Not Found page](https://laravel.com/docs/10.x/errors#custom-http-error-pages), use
489-
the name `errors.404`:
491+
To add breadcrumbs to a [custom 404 Not Found page](https://laravel.com/docs/errors#custom-http-error-pages), use the
492+
name `errors.404`:
490493

491494
```php
492495
Breadcrumbs::for('errors.404', function (BreadcrumbTrail $trail) {
@@ -576,7 +579,7 @@ Breadcrumbs::for('post', function (BreadcrumbTrail $trail, Post $post) { // <--
576579

577580
This makes your code less verbose and more efficient by only loading the post from the database once.
578581

579-
For more details see [Route Model Binding](https://laravel.com/docs/10.x/routing#route-model-binding) in the Laravel
582+
For more details see [Route Model Binding](https://laravel.com/docs/routing#route-model-binding) in the Laravel
580583
documentation.
581584

582585
### Resourceful controllers
@@ -641,7 +644,7 @@ Breadcrumbs::for('photo.edit', function (BreadcrumbTrail $trail, Photo $photo) {
641644
});
642645
```
643646

644-
For more details see [Resource Controllers](https://laravel.com/docs/10.x/controllers#resource-controllers) in the
647+
For more details see [Resource Controllers](https://laravel.com/docs/controllers#resource-controllers) in the
645648
Laravel documentation.
646649

647650
(Related FAQ: [Why is there no Breadcrumbs::resource() method?](#why-is-there-no-breadcrumbsresource-method).)
@@ -742,7 +745,7 @@ Breadcrumbs::after(function (BreadcrumbTrail $trail) {
742745
```
743746

744747
For more advanced filtering, use `Breadcrumbs::generate()` and Laravel's
745-
[Collection class](https://laravel.com/api/10.x/Illuminate/Support/Collection.html) methods instead:
748+
[Collection class](https://laravel.com/api/master/Illuminate/Support/Collection.html) methods instead:
746749

747750
```php
748751
<?php
@@ -754,8 +757,8 @@ $current = Breadcrumbs::generate()->where('current', '!==', false)->last();
754757

755758
### Switching views at runtime
756759

757-
You can use `Breadcrumbs::view()` in place of `Breadcrumbs::render()` to render a template other than the
758-
[default one](#3-style):
760+
You can use `Breadcrumbs::view()` in place of `Breadcrumbs::render()` to render a template other than
761+
the [default one](#3-style):
759762

760763
```blade
761764
{{ Breadcrumbs::view('partials.breadcrumbs2', 'category', $category) }}
@@ -846,7 +849,7 @@ class MyServiceProvider extends ServiceProvider
846849

847850
### Dependency injection
848851

849-
You can use [dependency injection](https://laravel.com/docs/10.x/providers#the-boot-method) to access the `Manager`
852+
You can use [dependency injection](https://laravel.com/docs/providers#the-boot-method) to access the `Manager`
850853
instance if you prefer, instead of using the `Breadcrumbs::` facade:
851854

852855
```php
@@ -866,9 +869,8 @@ class MyServiceProvider extends ServiceProvider
866869

867870
### Macros
868871

869-
The breadcrumbs `Manager` class is
870-
[macroable](https://unnikked.ga/understanding-the-laravel-macroable-trait-dab051f09172), so you can add your own
871-
methods. For example:
872+
The breadcrumbs `Manager` class is [macroable](https://tighten.com/insights/the-magic-of-laravel-macros/), so you can
873+
add your own methods. For example:
872874

873875
```php
874876
<?php
@@ -912,7 +914,7 @@ FAQ
912914
### Why is there no `Breadcrumbs::resource()` method?
913915

914916
A few people have suggested adding `Breadcrumbs::resource()` to match
915-
[`Route::resource()`](https://laravel.com/docs/10.x/controllers#resource-controllers), but no one has come up with a
917+
[`Route::resource()`](https://laravel.com/docs/controllers#resource-controllers), but no one has come up with a
916918
good implementation that a) is flexible enough to deal with translations, nested resources, etc., and b) isn't overly
917919
complex as a result.
918920

@@ -1104,6 +1106,7 @@ The following files will need to be updated to run tests against a new Laravel v
11041106
- [`composer.json`](composer.json)
11051107
- `laravel/framework` (Laravel versions)
11061108
- `php` (minimum PHP version)
1109+
- Other dependencies (prefer bumping to the highest-available versions that work for all Laravel/PHP combinations)
11071110

11081111
- [`tests.yml`](.github/workflows/tests.yml)
11091112
- `jobs.phpunit.strategy.matrix.laravel` (Laravel versions)
@@ -1114,7 +1117,6 @@ And the following documentation, as needed:
11141117

11151118
- [`README.md`](README.md)
11161119
- [Compatibility Chart](#compatibility-chart)
1117-
- All links to `https://laravel.com/docs/*` and `https://laravel.com/api/*`
11181120

11191121
- [`UPGRADE.md`](UPGRADE.md)
11201122
- Add new section detailing any breaking package changes

UPGRADE.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Upgrade Guide
22

3+
## Upgrading to 9.x from 8.x
4+
5+
`9.x` drops support for Laravel v6 and v7 to support PHPUnit v10. There are no other breaking changes. If you're on
6+
Laravel v8+, you may simply re-run `composer require diglactic/laravel-breadcrumbs`.
7+
38
## Upgrading to 8.x from 7.x
49

510
`8.x` introduces a single breaking change over `7.x` by passing request parameters injected by middleware into
@@ -27,7 +32,7 @@ to this repository. Note that this library requires at least Laravel 6.
2732

2833
Begin by swapping libraries via Composer:
2934

30-
```shell script
35+
```shell
3136
composer remove davejamesmiller/laravel-breadcrumbs
3237
composer require diglactic/laravel-breadcrumbs
3338
```

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
],
2020
"license": "MIT",
2121
"require": {
22-
"php": "^7.2 || ^8.0",
22+
"php": "^7.3 || ^8.0",
2323
"facade/ignition-contracts": "^1.0",
24-
"laravel/framework": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0"
24+
"laravel/framework": "^8.0 || ^9.0 || ^10.0 || ^11.0"
2525
},
2626
"require-dev": {
27-
"orchestra/testbench": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0",
28-
"phpunit/phpunit": "^8.5 || ^9.5",
29-
"php-coveralls/php-coveralls": "^2.4",
30-
"spatie/phpunit-snapshot-assertions": "^2.2 || ^4.2"
27+
"orchestra/testbench": "^6.0 || ^7.0 || ^8.0 || ^9.0",
28+
"phpunit/phpunit": "^9.5 || ^10.5",
29+
"php-coveralls/php-coveralls": "^2.7",
30+
"spatie/phpunit-snapshot-assertions": "^4.2 || ^5.1"
3131
},
3232
"minimum-stability": "dev",
3333
"prefer-stable": true,

phpunit.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
35
backupGlobals="false"
46
backupStaticAttributes="false"
57
beStrictAboutChangesToGlobalState="true"
@@ -15,19 +17,17 @@
1517
stopOnFailure="false"
1618
verbose="true"
1719
>
18-
1920
<!-- List of files with tests inside -->
2021
<testsuites>
2122
<testsuite name="Package Test Suite">
2223
<directory suffix="Test.php">tests/</directory>
2324
</testsuite>
2425
</testsuites>
25-
26+
2627
<!-- List of source files for code coverage checker -->
27-
<filter>
28-
<whitelist processUncoveredFilesFromWhitelist="true">
28+
<coverage processUncoveredFiles="true">
29+
<include>
2930
<directory suffix=".php">src/</directory>
30-
</whitelist>
31-
</filter>
32-
31+
</include>
32+
</coverage>
3333
</phpunit>

tests/CustomGeneratorTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,4 @@ public function generate(array $callbacks, array $before, array $after, string $
3030
{
3131
return new Collection(['custom-generator']);
3232
}
33-
3433
}

tests/DeferredLoadingTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protected function getEnvironmentSetUp($app): void
1717
$app->config->set('breadcrumbs.files', [__DIR__ . '/routes/should-not-be-loaded.php']);
1818
}
1919

20-
protected function resolveApplicationConsoleKernel($app)
20+
protected function resolveApplicationConsoleKernel($app): void
2121
{
2222
// Disable the console kernel because it calls loadDeferredProviders()
2323
// which defeats the purpose of this test
@@ -36,7 +36,7 @@ public function testDeferredLoading()
3636

3737
class DisabledConsoleKernel extends \Orchestra\Testbench\Foundation\Console\Kernel
3838
{
39-
public function bootstrap()
39+
public function bootstrap(): void
4040
{
4141
//
4242
}

tests/FacadePhpDocTest.php

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Diglactic\Breadcrumbs\Breadcrumbs;
66
use Diglactic\Breadcrumbs\Manager;
7+
use Generator;
78
use Illuminate\Support\Str;
89
use Illuminate\Support\Traits\Macroable;
910
use ReflectionClass;
@@ -13,7 +14,7 @@
1314

1415
class FacadePhpDocTest extends TestCase
1516
{
16-
public function tags()
17+
public static function tags(): Generator
1718
{
1819
$code = file_get_contents(__DIR__ . '/../src/Manager.php');
1920

@@ -38,24 +39,6 @@ public function tags()
3839
}
3940
}
4041

41-
/** @dataProvider tags */
42-
public function testFullyQualifiedClassNames($class, $line)
43-
{
44-
// IDE Helper (v2.4.3) doesn't rewrite class names to FQCNs, so make sure only
45-
// fully qualified class names and built-in types are used in the Manager class
46-
// ----------------------------------------------------------------------------
47-
// Note: we'll eventually need to update with `assertMatchesRegularExpression`.
48-
// This is currently slated for removal in PHPUnit 10, but hasn't been enforced
49-
// yet. Laravel 10 supports PHPUnit 10 and 9, so we've stuck with v9 for now.
50-
// @see https://github.com/laravel/framework/blob/10.x/composer.json#L101
51-
// @see https://github.com/sebastianbergmann/phpunit/issues/4086
52-
$this->assertRegExp(
53-
'/^(\\\\.*|array|object|bool|callable|int|mixed|null|string|void)$/',
54-
$class,
55-
"Must use fully qualified class names in BreadcrumbsManger PhpDoc: $line"
56-
);
57-
}
58-
5942
public function testBreadcrumbsFacade()
6043
{
6144
$class = new ReflectionClass(Manager::class);

0 commit comments

Comments
 (0)