GithubHelp home page GithubHelp logo

wulfheart / pretty-routes Goto Github PK

View Code? Open in Web Editor NEW
628.0 6.0 33.0 1.68 MB

Display your Laravel routes in the console, but make it pretty. 😎

License: MIT License

PHP 100.00%
laravel laravel-framework routes console artisan artisan-command

pretty-routes's Introduction

Pretty Routes for Laravel

Latest Version on Packagist Total Downloads

Display your Laravel routes in the console, but make it pretty. 😎

Note

With the arrival of Laravel 9 this package is going to be deprecated as the functionality will already be integrated in the framework as per this PR. Thanks for the support! ⭐

Installation

You can install the package via composer:

composer require wulfheart/pretty_routes

Usage

php artisan route:pretty

or

php artisan route:pretty --except-path=horizon --method=POST --reverse
php artisan route:pretty --only-path=app --method=POST --reverse
php artisan route:pretty --only-name=app --method=POST 
php artisan route:pretty --only-name=app --method=POST --group=path --reverse-group
php artisan route:pretty --only-name=app,horizon,debugbar --except-path=foo,bar --group=name --reverse

Advanced Example

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Feel free to open an issue or a PR. Discussions are disabled right now as there shouldn't be too much need for discussion and it can happen in the issues.

Credits

License

The MIT License (MIT). Please see License File for more information.

pretty-routes's People

Contributors

bhushan avatar gummibeer avatar infostreams avatar mattstauffer avatar teodoriu avatar wulfheart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pretty-routes's Issues

Lumen compatibility?

Is there any plan to support Lumen? Is there any specific reason to start from ^8.x?

Install fails

composer require wulfheart/pretty_routes:^0.3.0

./composer.json has been updated
Running composer update wulfheart/pretty_routes
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires wulfheart/pretty_routes 0.3.0 -> satisfiable by wulfheart/pretty_routes[0.3.0].
    - wulfheart/pretty_routes 0.3.0 requires illuminate/contracts ^8.0 -> found illuminate/contracts[v8.0.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with another require.


Installation failed, reverting ./composer.json and ./composer.lock to their original content.

Option to display controller and method

Is your feature request related to a problem? Please describe.

I have a big project with more than 50 controllers scattered around different packages. Sometimes I have a path but I want to find the controller and the method.

Now I use route:pretty to get the route name and then search for the route’s name in the router.php to find the controller and method.

Describe the solution you'd like

An option to display the controller’s class name and method instead of the name.

Describe alternatives you've considered

Using route:list but it’s not possible to see all routes since I cannot scroll to the top of the list. Also it’s hard to read when the app I complex.

Thanks for creating this package. I still find this 100% more useful than artisan route:list!

System (please complete the following information):

  • OS: [e.g. macOS, Manjaro Linux, Windows 10]
  • PHP Version: [e.g. 8.0.3]]
  • Package Version from the lock-file: [e.g. 0.2.2]
  • Laravel Version from the lock-file: [e.g. 8.5.2]
  • Shell: [e.g. Powershell, cmd, bash, zsh]

macOS. Php 8.0.3. Zsh.

str_repeat(): Argument #2 ($times) must be greater than or equal to 0

Getting this error in the console after running php artisan route:pretty:

ValueError

 str_repeat(): Argument #2 ($times) must be greater than or equal to 0

 at vendor/wulfheart/pretty_routes/src/Commands/PrettyRoutesCommand.php:161
   157β–•             $method = $route["method"];
   158β–•             $uri = $route["uri"];
   159β–•             $name = $route["name"];
   160β–•
 ➜ 161β–•             $spaces = str_repeat(' ', $maxMethod + 6 - strlen($method));
   162β–•
   163β–•             $additionalSpace = ! is_null($name) ? 1 : 0;
   164β–•             $dots = str_repeat('.', max($terminalWidth - strlen($method.$uri.$name) - strlen($spaces) - 14 - $additionalSpace, 0));
   165β–•

     +15 vendor frames
 16  artisan:37
     Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

It doesn't finish printing out my routes.

The route that it stops printing at is:

Route::any('encounters/{encounter}/pdf', [EncounterController::class, 'pdf'])->name('encounter.pdf');

Add option to see middlewares in pretty

Is your feature request related to a problem? Please describe.
No

Describe the solution you'd like
It would be nice to have an option to see the middlewares for a route in pretty.

Describe alternatives you've considered

Additional context

Error after install package in Laravel 8

ParseError
syntax error, unexpected 'Package' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)

::Composer\Autoload\includeFile
E:\wamp64\www\AcodePlus\vendor\spatie\laravel-package-tools\src\PackageServiceProvider.php:14

`<?php

 

namespace Spatie\LaravelPackageTools;

 

use Carbon\Carbon;

use Illuminate\Support\Facades\View;

use Illuminate\Support\ServiceProvider;

use Illuminate\Support\Str;

use ReflectionClass;

use Spatie\LaravelPackageTools\Exceptions\InvalidPackage;

 

abstract class PackageServiceProvider extends ServiceProvider

{

    protected Package $package;   <-- error here (line 14)
 

    abstract public function configurePackage(Package $package): void;

 

    public function register()

    {

        $this->registeringPackage();

 

        $this->package = new Package();

 

        $this->package->setBasePath($this->getPackageBaseDir());

 

        $this->configurePackage($this->package);

 

        if (empty($this->package->name)) {

            throw InvalidPackage::nameIsRequired();

        }`

 

Idea: Config file to exclude paths all the time

Having to always type out the --only-name or --except-path gets kinda tedious. I would love to be able to set these in a config file.

i.e.

<?php

return [
    'exclude' => [
        'horizon',
        'telescope',
        ...
    ]
];

Not compatible with Laravel 7

When I try to install it on my Laravel 7 project it shows this problem

Problem 1
- Root composer.json requires wulfheart/pretty_routes ^0.3.0 -> satisfiable by wulfheart/pretty_routes[0.3.0].
- wulfheart/pretty_routes 0.3.0 requires illuminate/contracts ^8.0 -> found illuminate/contracts[v8.0.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with another require.

Error when running php artisan route:pretty

When trying to run php artisan route:pretty , I get this error :
` ErrorException

Undefined array key 0

at vendor/laravel/framework/src/Illuminate/Routing/Router.php:1286
1282β–• if ($method === 'middleware') {
1283β–• return (new RouteRegistrar($this))->attribute($method, is_array($parameters[0]) ? $parameters[0] : $parameters);
1284β–• }
1285β–•
➜ 1286β–• return (new RouteRegistrar($this))->attribute($method, $parameters[0]);
1287β–• }
1288β–• }
1289β–•

  Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

`

My project use Laravel 8.5.9

Add --except-path to config file

Just a thought here, maybe it'd nice to move the config inside the config file and let the user overwrite them if they explicitly put it in the command.

str_repeat(): Argument #2 ($times) must be greater than or equal to 0

└─[$] <git:(pretty_routes*)> sail artisan route:pretty
  GET|HEAD / ..................................................... index
  GET|HEAD _debugbar/assets/javascript .............. debugbar.assets.js
  GET|HEAD _debugbar/assets/stylesheets ............ debugbar.assets.css
  DELETE   _debugbar/cache/{key}/{tags?} ......... debugbar.cache.delete
  GET|HEAD _debugbar/clockwork/{id} ................. debugbar.clockwork
  GET|HEAD _debugbar/open ......................... debugbar.openhandler
  GET|HEAD _debugbar/telescope/{id} ................. debugbar.telescope
  GET|HEAD api/user .................................................... 

   ValueError 

  str_repeat(): Argument #2 ($times) must be greater than or equal to 0

  at vendor/wulfheart/pretty_routes/src/Commands/PrettyRoutesCommand.php:161
    157β–•             $method = $route["method"];
    158β–•             $uri = $route["uri"];
    159β–•             $name = $route["name"];
    160β–• 
  ➜ 161β–•             $spaces = str_repeat(' ', $maxMethod + 6 - strlen($method));
    162β–• 
    163β–•             $additionalSpace = ! is_null($name) ? 1 : 0;
    164β–•             $dots = str_repeat('.', max($terminalWidth - strlen($method.$uri.$name) - strlen($spaces) - 14 - $additionalSpace, 0));
    165β–• 

      +15 vendor frames 
  16  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

do you have any idea why this happens / do you need more information about my route definitions for this problem to solve?

thanks a lot !

Laravel 9 support

Hello,
Could you please update your great package to support Laravel 9 ?

Roadmap needed

I like this package I want to contribute to it but this package is going crazily in different directions with each PR. Each PR is with a different implementation strategy. Once @Wulfheart decides the path to go with which PRs. I will share the next PRs, as I am not sure which implementations you will keep.

I think we should have some kind of roadmap or something..

@Gummibeer @Wulfheart what you guys think about this?

-d --update-snapshots flag is needed for the phpunit tests to work

Screenshot 2021-04-30 at 1 52 17 AM

If a new contributor forks the project and runs the tests .. then it fails .. and it suggests adding -d --update-snapshots flag with the PHP unit command.. then tests works fine.

but the problem is snapshots output file is modified and then it will be part of new PR. SO each new PR will have its own snapshot version.

Filtering for route names

What if we have a new custom flag which will show only the routes we want

β€”show=tickets

it will show only routes which has tickets in it.

If you think its good i can send you a PR.

group by domain

I have using Laravel with a multi subdomains, e.g.

  • mydomain.tld as frontend
  • admin.mydomain.tld as backend
  • api.mydomain.tld as API

I configure them from App\Providers\RouteServiceProvider
can I use your package to show all routes grouped by domain?
thanks.

The "--only-path" option does not exist.

PHP 8.0.3. Laravel app: (current) 8.40.0. (shell alias art for php artisan in below commands)

This is great tool THANK YOU for making it. Command works without options. In addition to the issue previously reported re: str_repeat(): Argument #2 ($times) must be greater than or equal to 0 - which is still present for me in php8... (I get that when I run art route:pretty --method=POST)

When I run:

art route:pretty --only-path=transactions (to be clear, there is in fact a path transactions)

I get The "--only-path" option does not exist.

Screen Shot 2021-04-29 at 9 34 32 AM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.