Skip to content

Commit 7e77e2c

Browse files
author
Andrey Helldar
authored
Merge pull request #1 from andrey-helldar/upgrade
Upgrade to self-contained
2 parents 5ccc9da + 11d1abb commit 7e77e2c

File tree

13 files changed

+339
-61
lines changed

13 files changed

+339
-61
lines changed
120 KB
Loading

.styleci.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
preset: psr12
2+
3+
risky: true
4+
5+
enabled:
6+
- align_double_arrow
7+
- align_equals
8+
- align_phpdoc
9+
- alpha_ordered_imports
10+
- binary_operator_spaces
11+
- blank_line_before_continue
12+
- blank_line_before_declare
13+
- blank_line_before_return
14+
- blank_line_before_throw
15+
- blank_line_before_try
16+
- cast_spaces
17+
- combine_consecutive_issets
18+
- const_separation
19+
- dir_constant
20+
- fully_qualified_strict_types
21+
- logical_operators
22+
- method_separation
23+
- no_alias_functions
24+
- no_blank_lines_after_phpdoc
25+
- no_blank_lines_between_traits
26+
- no_empty_comment
27+
- no_empty_phpdoc
28+
- no_extra_block_blank_lines
29+
- no_extra_consecutive_blank_lines
30+
- no_short_bool_cast
31+
- no_trailing_comma_in_singleline_array
32+
- no_unneeded_control_parentheses
33+
- no_unused_imports
34+
- ordered_class_elements
35+
- php_unit_construct
36+
- php_unit_fqcn_annotation
37+
- phpdoc_indent
38+
- phpdoc_inline_tag
39+
- phpdoc_link_to_see
40+
- phpdoc_no_access
41+
- phpdoc_no_empty_return
42+
- phpdoc_no_package
43+
- phpdoc_no_useless_inheritdoc
44+
- phpdoc_order
45+
- phpdoc_property
46+
- phpdoc_return_self_reference
47+
- phpdoc_scalar
48+
- phpdoc_separation
49+
- phpdoc_summary
50+
- phpdoc_to_comment
51+
- phpdoc_trim
52+
- phpdoc_type_to_var
53+
- phpdoc_types
54+
- phpdoc_types_order
55+
- phpdoc_var_without_name
56+
- property_separation
57+
- self_accessor
58+
- short_array_syntax
59+
- short_list_syntax
60+
- single_line_class_definition
61+
- single_line_throw
62+
- single_quote
63+
- space_after_semicolon
64+
- standardize_not_equals
65+
- ternary_to_null_coalescing
66+
- trailing_comma_in_multiline_array
67+
- trim_array_spaces

composer.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
{
2-
"name": "garygreen/pretty-routes",
3-
"description": "Pretty routes for Laravel 5.",
2+
"name": "andrey-helldar/pretty-routes",
3+
"description": "Pretty routes for Laravel 6+",
44
"require": {
5-
"laravel/framework": "5.*|6.*|7.*"
5+
"php": "7.2",
6+
"doctrine/annotations": "^1.0",
7+
"laravel/framework": "^6.0|^7.0|^8.0"
68
},
79
"license": "MIT",
810
"authors": [
911
{
1012
"name": "Gary Green",
1113
"email": "[email protected]"
14+
},
15+
{
16+
"name": "Andrey Helldar",
17+
"email": "[email protected]"
1218
}
1319
],
1420
"autoload": {
1521
"psr-4": {
1622
"PrettyRoutes\\": "src"
1723
}
1824
},
19-
"minimum-stability": "dev",
25+
"minimum-stability": "stable",
2026
"extra": {
2127
"laravel": {
2228
"providers": [
Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
11
<?php
22

33
return [
4-
5-
/**
4+
/*
65
* The endpoint to access the routes.
76
*/
8-
'url' => 'routes',
7+
'url' => 'routes',
98

10-
/**
9+
/*
1110
* The middleware(s) to apply before attempting to access routes page.
1211
*/
13-
'middlewares' => [],
12+
'middlewares' => [],
1413

15-
/**
14+
/*
1615
* Indicates whether to enable pretty routes only when debug is enabled (APP_DEBUG).
1716
*/
18-
'debug_only' => true,
17+
'debug_only' => true,
1918

20-
/**
19+
/*
2120
* The methods to hide.
2221
*/
23-
'hide_methods' => [
22+
'hide_methods' => [
2423
'HEAD',
2524
],
2625

27-
/**
26+
/*
2827
* The routes to hide with regular expression
2928
*/
3029
'hide_matching' => [
3130
'#^_debugbar#',
3231
'#^_ignition#',
33-
'#^routes$#'
32+
'#^routes$#',
3433
],
35-
3634
];

readme.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ Pretty Routes for Laravel
33

44
Visualise your routes in pretty format.
55

6-
![Pretty Routes](https://raw.githubusercontent.com/garygreen/pretty-routes/master/screenshot.png)
6+
<p align="center">
7+
<img src="/.github/home-page-images/screenshot.png?raw=true" alt="Pretty Routes"/>
8+
</p>
79

810
# Installation
911

1012
```bash
11-
composer require garygreen/pretty-routes
13+
composer require andrey-helldar/pretty-routes
1214
```
1315

1416
If your using autodiscovery in Laravel, it should just work.
@@ -19,12 +21,12 @@ Otherwise - add to your `config/app.php` providers array to where all your packa
1921
PrettyRoutes\ServiceProvider::class,
2022
```
2123

22-
By default the package exposes a `/routes` url. If you wish to configure this, publish the config.
24+
By default, the package exposes a `/routes` url. If you wish to configure this, publish the config.
2325

2426
```bash
2527
php artisan vendor:publish --provider="PrettyRoutes\ServiceProvider"
2628
```
2729

2830
If accessing `/routes` isn't working, ensure that you've included the provider within the same area as all your package providers (before all your app's providers) to ensure it takes priority.
2931

30-
By default pretty routes only enables itself when `APP_DEBUG` env is true. You can configure this on the published config as above, or add any custom middlewares.
32+
By default, pretty routes only enables itself when `APP_DEBUG` env is true. You can configure this on the published config as above, or add any custom middlewares.

views/routes.blade.php renamed to resources/views/routes.blade.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
padding: 0.30em 0.8em;
3030
}
3131
32+
.strike {
33+
text-decoration: line-through;
34+
}
35+
3236
table.hide-domains .domain {
3337
display: none;
3438
}
@@ -61,7 +65,7 @@
6165
<td class="domain{{ strlen($route->domain()) == 0 ? ' domain-empty' : '' }}">{{ $route->domain() }}</td>
6266
<td>{!! preg_replace('#({[^}]+})#', '<span class="text-warning">$1</span>', $route->uri()) !!}</td>
6367
<td>{{ $route->getName() }}</td>
64-
<td>{!! preg_replace('#(@.*)$#', '<span class="text-warning">$1</span>', $route->getActionName()) !!}</td>
68+
<td class="{{ \PrettyRoutes\Facades\Annotation::isDeprecated($route->getActionName()) ? 'strike' : '' }}">{!! preg_replace('#(@.*)$#', '<span class="text-warning">$1</span>', $route->getActionName()) !!}</td>
6569
<td>
6670
@if (is_callable([$route, 'controllerMiddleware']))
6771
{{ implode(', ', array_map($middlewareClosure, array_merge($route->middleware(), $route->controllerMiddleware()))) }}

routes/web.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Route;
4+
5+
Route::name('pretty-routes.show')
6+
->middleware(config('pretty-routes.middlewares'))
7+
->get(config('pretty-routes.url'), 'PrettyRoutes\PrettyRoutesController@show');

screenshot.png

-156 KB
Binary file not shown.

src/Facades/Annotation.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace PrettyRoutes\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
use PrettyRoutes\Support\Annotation as Support;
7+
8+
/**
9+
* @method static boolean isDeprecated(string $controller, string $method = null)
10+
* @method static boolean isDeprecatedClass(string $controller)
11+
* @method static boolean isDeprecatedMethod(string $controller, string $method)
12+
*/
13+
class Annotation extends Facade
14+
{
15+
protected static function getFacadeAccessor()
16+
{
17+
return Support::class;
18+
}
19+
}

src/PrettyRoutesController.php

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
1-
<?php namespace PrettyRoutes;
1+
<?php
22

3-
use Route;
4-
use Closure;
3+
namespace PrettyRoutes;
54

6-
class PrettyRoutesController {
5+
use Closure;
6+
use Illuminate\Routing\Controller as BaseController;
7+
use PrettyRoutes\Support\Routes;
78

9+
class PrettyRoutesController extends BaseController
10+
{
811
/**
912
* Show pretty routes.
1013
*
14+
* @param \PrettyRoutes\Support\Routes $routes
15+
*
1116
* @return \Illuminate\Http\Response
1217
*/
13-
public function show()
18+
public function show(Routes $routes)
1419
{
1520
$middlewareClosure = function ($middleware) {
1621
return $middleware instanceof Closure ? 'Closure' : $middleware;
1722
};
1823

19-
$routes = collect(Route::getRoutes());
20-
21-
foreach (config('pretty-routes.hide_matching') as $regex) {
22-
$routes = $routes->filter(function ($value, $key) use ($regex) {
23-
return !preg_match($regex, $value->uri());
24-
});
25-
}
26-
2724
return view('pretty-routes::routes', [
28-
'routes' => $routes,
25+
'routes' => $routes->get(),
2926
'middlewareClosure' => $middlewareClosure,
3027
]);
3128
}
32-
3329
}

0 commit comments

Comments
 (0)