Skip to content

Commit 24d7e0b

Browse files
Merge pull request #142 from joaorobertopb/improvements
[2.x] Improvements
2 parents 8b0136c + a772973 commit 24d7e0b

File tree

10 files changed

+17
-136
lines changed

10 files changed

+17
-136
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ env:
99
matrix:
1010
fast_finish: true
1111
include:
12-
- php: 7.1
13-
- php: 7.1
14-
env: setup=lowest
1512
- php: 7.2
1613
- php: 7.2
1714
env: setup=lowest

README.md

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
</p>
44

55
<p align="center">
6-
<a href="https://gitscrum.com"><img src="https://site.gitscrum.com/badges/project.svg?project=gitscrum/bulls-eye-gitscrum-37" alt="GitScrum"></a>
7-
<a href="https://packagist.org/packages/renatomarinho/laravel-page-speed"><img src="https://poser.pugx.org/renatomarinho/laravel-page-speed/license" alt="License"></a>
6+
<a href="https://travis-ci.org/renatomarinho/laravel-page-speed"><img src="https://travis-ci.org/renatomarinho/laravel-page-speed.svg?branch=master" alt="Build Status"></a>
87
<a href="https://packagist.org/packages/renatomarinho/laravel-page-speed"><img src="https://poser.pugx.org/renatomarinho/laravel-page-speed/version" alt="Latest Stable Version"></a>
98
<a href="https://packagist.org/packages/renatomarinho/laravel-page-speed"><img src="https://poser.pugx.org/renatomarinho/laravel-page-speed/downloads" alt="Total Downloads"></a>
9+
<a href="https://packagist.org/packages/renatomarinho/laravel-page-speed"><img src="https://poser.pugx.org/renatomarinho/laravel-page-speed/license" alt="License"></a>
1010
</p>
1111

1212
# Laravel Page Speed
1313

14-
### Simple package to minify HTML output on demand which results in a 35%+ optimization.
14+
Simple package to minify HTML output on demand which results in a 35%+ optimization. Laravel Page Speed was created by [Renato Marinho][link-author], and currently maintained by [João Roberto P. Borges][link-maintainer], [Lucas Mesquita Borges][link-maintainer-2] and [Renato Marinho][link-author].
1515

1616
## Installation
1717

1818
> **Requires:**
19-
- **[PHP 7.1.3+](https://php.net/releases/)**
20-
- **[Laravel 5.5+](https://github.com/laravel/laravel)**
19+
- **[PHP 7.2.5+](https://php.net/releases/)**
20+
- **[Laravel 6.0+](https://github.com/laravel/laravel)**
2121

2222
You can install the package via composer:
2323

@@ -44,8 +44,8 @@ protected $middleware = [
4444
\RenatoMarinho\LaravelPageSpeed\Middleware\ElideAttributes::class,
4545
\RenatoMarinho\LaravelPageSpeed\Middleware\InsertDNSPrefetch::class,
4646
\RenatoMarinho\LaravelPageSpeed\Middleware\RemoveComments::class,
47-
\RenatoMarinho\LaravelPageSpeed\Middleware\TrimUrls::class,
48-
\RenatoMarinho\LaravelPageSpeed\Middleware\RemoveQuotes::class,
47+
//\RenatoMarinho\LaravelPageSpeed\Middleware\TrimUrls::class,
48+
//\RenatoMarinho\LaravelPageSpeed\Middleware\RemoveQuotes::class,
4949
\RenatoMarinho\LaravelPageSpeed\Middleware\CollapseWhitespace::class, // Note: This middleware invokes "RemoveComments::class" before it runs.
5050
\RenatoMarinho\LaravelPageSpeed\Middleware\DeferJavascript::class,
5151
]
@@ -89,7 +89,7 @@ The **InsertDNSPrefetch::class** filter Injects <link rel="dns-prefetch" href="/
8989

9090
DNS resolution time varies from <1ms for locally cached results, to hundreds of milliseconds due to the cascading nature of DNS. This can contribute significantly towards total page load time. This filter reduces DNS lookup time by providing hints to the browser at the beginning of the HTML, which allows the browser to pre-resolve DNS for resources on the page.
9191

92-
### \RenatoMarinho\LaravelPageSpeed\Middleware\TrimUrls::class,
92+
### ⚠️ \RenatoMarinho\LaravelPageSpeed\Middleware\TrimUrls::class,
9393

9494
The **TrimUrls::class** filter trims URLs by resolving them by making them relative to the base URL for the page.
9595

@@ -140,18 +140,6 @@ By default this field comes configured with some options, so feel free to config
140140

141141
> *Notice*: This package skip automatically 'binary' and 'streamed' responses. See [File Downloads][link-file-download].
142142
143-
### Disable Middleware
144-
145-
All middlewares operate with Auto-Discover. However, there are times when you do not want to use a specific middleware.
146-
147-
```php
148-
//config/laravel-page-speed.php
149-
150-
'disabled_middlewares' => [
151-
\RenatoMarinho\LaravelPageSpeed\Middleware\TrimUrls::class,
152-
];
153-
```
154-
155143
## Testing
156144

157145
```sh
@@ -162,10 +150,8 @@ $ composer test
162150

163151
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
164152

165-
## Credits
153+
## Contributors
166154

167-
- [Renato Marinho][link-author]
168-
- [João Roberto P. Borges][link-maintainer]
169155
- [Caneco](https://twitter.com/caneco) (for the logo)
170156
- [All Contributors][link-contributors]
171157

@@ -181,6 +167,7 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
181167
[link-after]: https://i.imgur.com/IKWKLkL.png
182168
[link-author]: https://github.com/renatomarinho
183169
[link-maintainer]: https://github.com/joaorobertopb
170+
[link-maintainer-2]: https://github.com/lucasMesquitaBorges
184171
[link-contributors]: ../../contributors
185172
[link-file-download]: https://laravel.com/docs/6.0/responses#file-downloads
186173
[link-package-discovery]: https://laravel.com/docs/6.0/packages#package-discovery

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
}
1717
],
1818
"require": {
19-
"php": "^7.1.3 || ^8.0",
20-
"illuminate/support": "^5.5 || ^6.0 || ^7.0 || ^8.0"
19+
"php": "^7.2.5 || ^8.0",
20+
"illuminate/support": "^6.0 || ^7.0 || ^8.0"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "^7.5 || ^8.0 || ^9.0",
24-
"orchestra/testbench": "^3.5 || ^4.0 || ^5.0 || ^6.0",
23+
"phpunit/phpunit": "^8.5 || ^9.0",
24+
"orchestra/testbench": "^4.0 || ^5.0 || ^6.0",
2525
"squizlabs/php_codesniffer": "^3.4",
26-
"mockery/mockery": "^1.3"
26+
"mockery/mockery": "^1.3.3"
2727
},
2828
"autoload": {
2929
"psr-4": {

config/laravel-page-speed.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,4 @@
5656
'*.m4v',
5757
'*.torrent'
5858
],
59-
60-
/*
61-
|--------------------------------------------------------------------------
62-
| Disabled Middlewares
63-
|--------------------------------------------------------------------------
64-
|
65-
| Middlewares to exclude. Using the Package Auto-Discovery.
66-
| Specify class name.
67-
|
68-
*/
69-
'disabled_middlewares' => [
70-
//
71-
],
7259
];

src/Middleware/CollapseWhitespace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public function apply($buffer)
2020

2121
protected function removeComments($buffer)
2222
{
23-
return (new RemoveComments)->apply($buffer);
23+
return (new RemoveComments)->apply($buffer);
2424
}
2525
}

src/Middleware/PageSpeed.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected function shouldProcessPageSpeed($request, $response)
8585
}
8686

8787
if ($response instanceof StreamedResponse) {
88-
return false;
88+
return false;
8989
}
9090

9191
$patterns = config('laravel-page-speed.skip', []);

src/ServiceProvider.php

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22

33
namespace RenatoMarinho\LaravelPageSpeed;
44

5-
use Illuminate\Contracts\Http\Kernel;
65
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
76

87
class ServiceProvider extends BaseServiceProvider
98
{
10-
private const MIDDLEWARES_PATH = __DIR__ . DIRECTORY_SEPARATOR . 'Middleware/';
11-
private const MIDDLEWARES_NAMESPACE = 'RenatoMarinho\\LaravelPageSpeed\\Middleware\\';
12-
private const ABSTRACT_MIDDLEWARE_PATH = 'RenatoMarinho\LaravelPageSpeed\Middleware\PageSpeed';
13-
149
/**
1510
* Indicates if loading of the provider is deferred.
1611
*
@@ -26,8 +21,6 @@ public function boot()
2621
$this->publishes([
2722
__DIR__.'/../config/laravel-page-speed.php' => config_path('laravel-page-speed.php'),
2823
]);
29-
30-
$this->registerMiddlewares();
3124
}
3225

3326
/**
@@ -37,36 +30,4 @@ public function register()
3730
{
3831
$this->mergeConfigFrom(__DIR__.'/../config/laravel-page-speed.php', 'laravel-page-speed.php');
3932
}
40-
41-
/**
42-
* Register package middlewares.
43-
*/
44-
protected function registerMiddlewares()
45-
{
46-
$middlewares = collect($this->getMiddlewares())
47-
->diff(config('laravel-page-speed.disabled_middlewares', []))
48-
->reject(function ($middleware) {
49-
return $middleware === self::ABSTRACT_MIDDLEWARE_PATH;
50-
});
51-
52-
foreach ($middlewares as $middleware) {
53-
$this->app[Kernel::class]->pushMiddleware($middleware);
54-
}
55-
}
56-
57-
private function getMiddlewares()
58-
{
59-
$middlewaresFiles = glob(self::MIDDLEWARES_PATH . '*.php');
60-
61-
return array_map(function ($middleware) {
62-
return $this->transformMiddlewareFilePathToNamespace($middleware);
63-
}, $middlewaresFiles);
64-
}
65-
66-
private function transformMiddlewareFilePathToNamespace(string $middlewareFile)
67-
{
68-
$middlewareFile = str_replace('.php', '', $middlewareFile);
69-
70-
return str_replace(self::MIDDLEWARES_PATH, self::MIDDLEWARES_NAMESPACE, $middlewareFile);
71-
}
7233
}

tests/Config/DisabledMiddlewareIsEmptyTest.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/Config/DisabledMiddlewareTest.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/TestCase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,5 @@ protected function getEnvironmentSetUp($app)
5151
{
5252
config(['laravel-page-speed.enable' => true]);
5353
config(['laravel-page-speed.skip' => []]);
54-
config(['laravel-page-speed.disabled_middlewares' => []]);
5554
}
5655
}

0 commit comments

Comments
 (0)