Skip to content

Commit

Permalink
- Laravel 8
Browse files Browse the repository at this point in the history
  • Loading branch information
toni-suarez committed Mar 16, 2024
1 parent 57a3913 commit 47d2f10
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 59 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/tests-php8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ jobs:

strategy:
matrix:
laravel: ['10.*', '11.*']
php: [8.1, 8.2]
exclude:
- laravel: '11.*'
php: 8.1
laravel: ['8.*']
php: [8.0, 8.1]
fail-fast: false

name: Laravel ${{ matrix.laravel }}, PHP ${{ matrix.php }}
Expand Down
53 changes: 5 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,55 +48,12 @@ $ composer require suarez/laravel-utm-parameter

### Middleware

#### Laravel 11

Open the `bootstrap/app.php` file and append the `UtmParameters::class` inside the web-group

```php
# Laravel 11
return Application::configure(basePath: dirname(__DIR__))
...
->withMiddleware(function (Middleware $middleware) {
$middleware->web(append: [
Suarez\UtmParameter\Middleware\UtmParameters::class,
/* ... keep the existing middleware here */
]);
})
...
```

To enable UTM-Parameters only for certain requests to your site, add a new alias.

```php
# Laravel 11
use Suarez\UtmParameter\Middleware\UtmParameters;

->withMiddleware(function (Middleware $middleware) {
$middleware
->alias([
/* ... keep the existing mappings here */
'utm-parameters' => UtmParameters::class,
])
->web(append: [
/* ... keep the existing mappings here */
UtmParameters::class
]);
})
```

To apply UTM-Parameters to specific routes, use the following middleware: `utm-parameters`

```php
Route::middleware('utm-parameters')
->get('langing-page/{slug}', 'LandingPageController@show');
```

#### Laravel 10
#### Laravel 8

Open the `app/Http/Kernel.php` file and add a new item to the `web` middleware group:

```php
# Laravel 10 and below
# Laravel 8
protected $middlewareGroups = [
'web' => [
/* ... keep the existing middleware here */
Expand All @@ -105,11 +62,11 @@ protected $middlewareGroups = [
];
```

To enable UTM-Parameters only for certain requests to your site, add a new mapping to the `middlewareAliases` Array.
To enable UTM-Parameters only for certain requests to your site, add a new mapping to the `routeMiddleware` Array.

```php
# Laravel 10 and below
protected $middlewareAliases = [
# Laravel 8
protected $routeMiddleware = [
/* ... keep the existing mappings here */
'utm-parameters' => \Suarez\UtmParameter\Middleware\UtmParameters::class,
];
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
}
],
"require": {
"php": "^8.1|^8.2",
"illuminate/support": "^10.0|^11.0",
"illuminate/contracts": "^10.0|^11.0"
"php": "^8.0|^8.1|^8.2",
"illuminate/support": "^8.0",
"illuminate/contracts": "^8.0"
},
"require-dev": {
"nunomaduro/collision": "^7.0|^8.1",
"orchestra/testbench": "^7.0|^8.0|^9.0",
"phpunit/phpunit": "^9.5|^10.0",
"nunomaduro/collision": "^5.10",
"orchestra/testbench": "^6.22",
"phpunit/phpunit": "^9.5",
"friendsofphp/php-cs-fixer": "^3.0"
},
"autoload": {
Expand Down

0 comments on commit 47d2f10

Please sign in to comment.