├── .github └── FUNDING.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── composer.json ├── config └── routes_explorer.php ├── src ├── DataCollectors │ ├── ApiCallsCountCollector.php │ └── DataCollectorInterface.php ├── MIddleware │ └── RoutesExplorerMiddleware.php ├── Models │ └── ApiCallsCount.php ├── RoutesExplorer.php └── RoutesExplorerServiceProvider.php ├── stubs └── migration.stub └── views └── routes.blade.php /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | open_collective: infyomlabs 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | node_modules/ 3 | npm-debug.log 4 | .idea 5 | 6 | # Laravel 4 specific 7 | bootstrap/compiled.php 8 | app/storage/ 9 | 10 | # Laravel 5 & Lumen specific 11 | public/storage 12 | public/hot 13 | storage/*.key 14 | .env.*.php 15 | .env.php 16 | .env 17 | Homestead.yaml 18 | Homestead.json 19 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | ## 9th Aug 2017 - First Release 4 | 5 | #### New Features 6 | - Route Explorer with listing of all routes 7 | - Optional support for tracking api calls count 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 InfyOm Labs 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

InfyOm

2 | 3 | InfyOm Laravel Routes Explorer 4 | ========================== 5 | 6 | ## Documentation 7 | 8 | Read [Documentation](https://infyom.com/open-source/laravel-routes-explorer/docs) for detailed installation steps and usage. 9 | 10 | ## Support Us 11 | 12 | We have created [14+ Laravel packages](https://github.com/InfyOmLabs) and invested a lot of resources into creating these all packages and maintaining them. 13 | 14 | You can support us by either sponsoring us or buying one of our paid products. Or help us by spreading the word about us on social platforms via tweets and posts. 15 | 16 | ### Buy our Paid Products 17 | 18 | [![InfyGPT](https://assets.infyom.com/open-source/infygpt-inline.png)](https://bit.ly/infy-gpt) 19 | 20 | You can also check out our other paid products on [CodeCanyon](https://1.envato.market/BXAnR1). 21 | 22 | ### Sponsors 23 | 24 | [Become a sponsor](https://opencollective.com/infyomlabs#sponsor) and get your logo on our README on Github with a link to your site. 25 | 26 | 27 | 28 | ### Backers 29 | 30 | [Become a backer](https://opencollective.com/infyomlabs#backer) and get your image on our README on Github with a link to your site. 31 | 32 | 33 | 34 | ### Follow Us 35 | 36 | - [Twitter](https://twitter.com/infyom) 37 | - [Facebook](https://www.facebook.com/infyom) 38 | - [LinkedIn](https://in.linkedin.com/company/infyom-technologies) 39 | - [Youtube](https://www.youtube.com/channel/UC8IvwfChD6i7Wp4yZp3tNsQ) 40 | - [Contact Us](https://infyom.com/contact-us) 41 | 42 | ## Made with InfyOm Generator 43 | 44 | Also, Do not forget to add your website to [Made with InfyOm Generator List](https://github.com/InfyOmLabs/laravel-generator/blob/develop/made-with-generator.md) list. 45 | 46 | ## Security 47 | 48 | If you discover any security-related issues, create an issue using the issue tracker. 49 | 50 | ## Credits 51 | 52 | - [InfyOm Technologies](https://github.com/infyomlabs) 53 | - [All Contributors](../../contributors) 54 | 55 | ## License 56 | 57 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 58 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "infyomlabs/routes-explorer", 3 | "description": "Laravel Routes Explorer", 4 | "keywords": [ 5 | "laravel", 6 | "infyom", 7 | "api", 8 | "explorer", 9 | "routes" 10 | ], 11 | "license": "MIT", 12 | "authors": [ 13 | { 14 | "name": "Mitul Golakiya", 15 | "email": "me@mitul.me" 16 | } 17 | ], 18 | "require": { 19 | "php": ">=5.5.9", 20 | "illuminate/support": ">=5.0" 21 | }, 22 | "require-dev": { 23 | "phpunit/phpunit": ">=5.0", 24 | "mockery/mockery": ">=0.9" 25 | }, 26 | "autoload": { 27 | "psr-4": { 28 | "InfyOm\\RoutesExplorer\\": "src/" 29 | } 30 | }, 31 | "extra": { 32 | "laravel": { 33 | "providers": [ 34 | "\\InfyOm\\RoutesExplorer\\RoutesExplorerServiceProvider" 35 | ] 36 | } 37 | }, 38 | "funding": [ 39 | { 40 | "type": "opencollective", 41 | "url": "https://opencollective.com/infyomlabs" 42 | } 43 | ] 44 | } 45 | -------------------------------------------------------------------------------- /config/routes_explorer.php: -------------------------------------------------------------------------------- 1 | true, 16 | 17 | /* 18 | |-------------------------------------------------------------------------- 19 | | Routes Explorer route 20 | |-------------------------------------------------------------------------- 21 | | 22 | | On this url, routes explorer will be displayed 23 | | 24 | */ 25 | 26 | 'route' => 'routes-explorer', 27 | 28 | /* 29 | |-------------------------------------------------------------------------- 30 | | Routes Explorer view file name 31 | |-------------------------------------------------------------------------- 32 | | 33 | | this view file will be used to display a view 34 | | 35 | */ 36 | 37 | 'view' => 'infyomlabs::routes', 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Data Collectors 42 | |-------------------------------------------------------------------------- 43 | | 44 | | Various data collectors to collect data 45 | | 46 | */ 47 | 48 | 'collections' => [ 49 | 50 | // collect api calls count 51 | 'api_calls_count' => false, 52 | 53 | ], 54 | ]; 55 | -------------------------------------------------------------------------------- /src/DataCollectors/ApiCallsCountCollector.php: -------------------------------------------------------------------------------- 1 | $request->route()->uri(), 14 | ]); 15 | 16 | $apiCall->user_id = (\Auth::guest()) ? null : \Auth::id(); 17 | $apiCall->save(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/DataCollectors/DataCollectorInterface.php: -------------------------------------------------------------------------------- 1 | collect($request); 32 | } 33 | 34 | return $response; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Models/ApiCallsCount.php: -------------------------------------------------------------------------------- 1 | getRoutes(); 14 | 15 | /** @var \Illuminate\Routing\Route[] $allRoutes */ 16 | $namedRoutes = Route::getRoutes()->getRoutesByName(); 17 | 18 | $namedRoutesUri = []; 19 | foreach ($namedRoutes as $routeName => $route) { 20 | $namedRoutesUri[$route->uri] = $routeName; 21 | } 22 | 23 | $routes = []; 24 | foreach ($allRoutes as $route) { 25 | $routes[$route->uri] = [ 26 | 'name' => isset($namedRoutesUri[$route->uri]) ? $namedRoutesUri[$route->uri] : '', 27 | 'url' => $route->uri, 28 | 'methods' => implode(', ', $route->methods()), 29 | 'count' => 0, 30 | ]; 31 | } 32 | 33 | if (config('infyom.routes_explorer.collections.api_calls_count')) { 34 | $apiCallCount = ApiCallsCount::groupBy('url') 35 | ->select('url', \DB::raw('count(*) as total')) 36 | ->get(); 37 | 38 | foreach ($apiCallCount as $countObj) { 39 | $routes[$countObj->url]['count'] = $countObj->total; 40 | } 41 | } 42 | 43 | return $routes; 44 | } 45 | 46 | public function showRoutes() 47 | { 48 | $routes = $this->getRoutes(); 49 | 50 | return view(config('infyom.routes_explorer.view'))->with(['routes' => $routes]); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/RoutesExplorerServiceProvider.php: -------------------------------------------------------------------------------- 1 | publishes([ 20 | $configPath => config_path('infyom/routes_explorer.php'), 21 | ]); 22 | 23 | $migrationPath = __DIR__.'/../stubs/migration.stub'; 24 | $fileName = date('Y_m_d_His').'_'.'create_api_calls_count_table.php'; 25 | 26 | $this->publishes([ 27 | $migrationPath => database_path('migrations/'.$fileName), 28 | ], 'migrations'); 29 | 30 | $viewPath = __DIR__.'/../views/routes.blade.php'; 31 | 32 | $this->publishes([ 33 | $viewPath => resource_path('views/routes/routes.blade.php'), 34 | ], 'views'); 35 | 36 | $this->loadViewsFrom(__DIR__.'/../views', 'infyomlabs'); 37 | 38 | $router = $this->app['router']; 39 | $router->pushMiddlewareToGroup('api', RoutesExplorerMiddleware::class); 40 | 41 | if (config('infyom.routes_explorer.enable_explorer')) { 42 | $this->app['router']->get( 43 | config('infyom.routes_explorer.route'), 44 | '\\InfyOm\\RoutesExplorer\\RoutesExplorer@showRoutes' 45 | ); 46 | } 47 | } 48 | 49 | /** 50 | * Register any application services. 51 | * 52 | * @return void 53 | */ 54 | public function register() 55 | { 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /stubs/migration.stub: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | $table->string('url'); 19 | $table->unsignedInteger('user_id')->nullable(); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::dropIfExists('api_calls_count'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /views/routes.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | InfyOm Routes Explorer 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 37 | 38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |

All Routes

46 |
47 |
48 | 49 | 50 | 51 | 52 | 53 | @if (config('infyom.routes_explorer.collections.api_calls_count')) 54 | 55 | @endif 56 | 57 | 58 | @foreach($routes as $route) 59 | 60 | 61 | 62 | 63 | @if (config('infyom.routes_explorer.collections.api_calls_count')) 64 | 65 | @endif 66 | 67 | @endforeach 68 | 69 |
NameURLMethodsCount
{!! $route['name'] !!}{!! $route['url'] !!}{!! $route['methods'] !!}{!! $route['count'] !!}
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 99 | 100 | 101 | 102 | --------------------------------------------------------------------------------