
Beautify Laravel Route Views with Pretty Routes Package

Pretty Routes Laravel - On this occasion I will share an article that will discuss how to beautify the appearance of Laravel routes on the console using the pretty routes package. The pretty routes package was just published by Wulfheart a few days ago.
Before going to the steps on how to use it, let's get acquainted with the pretty routes package. Why do we need to use the pretty routes package? Actually, the use of this package is not mandatory, the pretty routes package can be used for people who are bored with the routes display in the console or when we run the php artisan route:list command.
Are you also among those who are bored with the route:list display on your console or terminal? If yes, then you are right to read this article. Maybe you can use this package to refresh your eyes when running or viewing the route list. How to use this package is also very easy, only a few commands you can see the results or display a more beautiful route list.
Alright let's try the pretty routes package in our laravel project.
composer require wulfheart/pretty_routes
The first step is very simple, you can see the complete documentation on the Wulfheart github account or you can directly run the command as above on your terminal. Wait until the process is complete and make sure the internet network is active and stable.
php artisan route:pretty
If the pretty routes package install process is complete, you can use it immediately or see the results simply by running the command as above in the terminal.
See how the result? very beautiful right? with a route list view like the picture above, it's more pleasing to the eye and easier to read what routes we have created or already exist in our laravel project. In contrast to the default route list display from Laravel, the display looks less neat and not easy to read. There are more options to use pretty routes in laravel like the options below.
php artisan route:pretty --except-path=books
With a command like the one above, it will present us with pretty routes with the exception that the path books will not be displayed. What is the result of the command above? see pictures and explanations below.
The result of the command php artisan route:pretty --except-path=books will produce a display like the image above. If we look at the first image with the second image (picture above) there is a difference, namely in the second image it does not display routes with path books, yes indeed in the command we have added --except-path=books which means displaying routes except routes with path books .
php artisan route:pretty --only-path=users
If previously there was --except-path=books which means showing all routes except routes with path books, there is also a command or command that serves to display routes with certain paths. The command or command can be seen above, with php artisan route:pretty --only-path=users will display a route that only has the path users. How is the result ? You can see pictures and explanations below.
The picture above is the result of the php artisan route:pretty --only-path=users command which serves to display a route list with the users path and of course with a more attractive and easy-to-read display using the pretty routes package.
php artisan route:pretty --method=GET
Then there is the pretty routes command option as above. The pretty routes command or command above is used when we only want to display a route list with methods only, so other than the GET method it will not be displayed in the console or terminal. How is the result ? can be seen again in the image and explanation below.
Well, the picture above is the result of the php artisan route:pretty --method=GET command. Can be seen in the picture above, in the terminal will only display the route with the GET method only.
php artisan route:pretty --method=POST
After the command to display the route with the GET method only, there is also a command that is used to view the route list with the POST method only, with the command above. Here we only change the method, where in the previous command we gave the value of the GET method and in the command above we only replaced it with POST.
The image above is the result of the command or command php artisan route:pretty --method=POST. Can you see the difference with the previous image? In the picture above only shows the route with the POST method and of course with a very attractive and easy to read appearance.
php artisan route:pretty --reverse
Then to reverse the order of the route, we can use the command or commands as above. Adding --reverse will give us the route display in reverse order and again of course with a beautiful, attractive and easy-to-read display.
The image above is the result of the php artisan route:pretty --reverse command or command. If we pay attention and we compare the image above with the first image, the results or the display order will not be the same because indeed with --reverse will display the route list in reverse order.
php artisan route:pretty --sort=method
The command or command route:pretty above serves to display a route list with the sort method. This means that the route list display will not be like for example with the order of the GET, POST, GET, GET, DELETE, POST methods but are sorted by method and to make it more clear can be seen in the picture and explanation below.
The picture above is a pretty route display with sorting by method. It can be seen, the order of the routes is neater by displaying or grouping by method.
php artisan route:pretty --except-path=books --method=POST
And the last example, we can also do a combination command as above. The above command serves to display all routes with the POST method with the exception of path books will not be displayed. How is the result ?
The results of the combination command can be seen in the image above. If we look and notice in the picture above, it only displays all routes with the POST method and no routes with path books. This means that the results are in accordance with what we want from the command combination php artisan route:pretty --except-path=books --method=POST.
So this article is about using the pretty routes package to beautify the appearance of laravel routes in the console or terminal. In this article we have both learned how to install pretty routes and also learned how to use them with various options or variations. For more complete use or information about pretty routes, you can see or learn on the official Wulfheart github account.
If there are criticisms, suggestions, input or anything that you want to discuss, don't hesitate to write a comment in the comment form below. See you in the next article with another no less interesting discussion. See you.
- Cara Mengatasi Error XAMPP: MySQL shutdown unexpectedly 23 Oktober 2021 67256 views
- Laravel 8: REST API Authentication dengan Sanctum 17 September 2021 32330 views
- Tutorial CRUD (Create, Read, Update & Delete) Codeigniter 4 dengan Bootstrap 14 Oktober 2021 32303 views
- Membuat REST API CRUD di Laravel 8 dengan Sanctum 18 September 2021 28603 views
- Contoh Cara Menggunakan Sweet Alert di Laravel 8 27 Agustus 2021 27948 views