Download the PHP package spatie/laravel-visit without Composer
On this page you can find all versions of the php package spatie/laravel-visit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download spatie/laravel-visit
More information about spatie/laravel-visit
Files in spatie/laravel-visit
Package laravel-visit
Short Description Quickly visit any route of your Laravel app
License MIT
Homepage https://github.com/spatie/laravel-visit
Informations about the package laravel-visit
Quickly visit any route of your Laravel app
This package contains an artisan command visit
that allows you to visit any route of your Laravel app.
The command display the colorized version of the HTML...
... followed by a results block.
The command can also colorize JSON output. It also has support for some Laravel niceties such as logging in users before making a request, using a route name instead of and URL, and much more.
Want to use visit
to visit any site
The spatie/visit
tool can be installed globally to visit any site.
Support us
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Installation
You can install the package via composer:
To colorize HTML, you should install bat
.
To colorize JSON, you should install jq
.
Optionally, you can publish the config file.
This is the content of the published config file:
Usage
To visit a certain page, execute php artisan
followed by a URL.
Instead of passing an URL, you can pass a route name to the route
option. Here's an example where we will visit the route named "contact".
Using a different method
By default, the visit
command will make GET request. To use a different HTTP verb, you can pass it to the method
option.
Passing a payload
You can pass a payload to non-GET request by using the payload. The payload should be formatted as JSON.
When you pass a payload, we'll assume that you want to make a POST
request. If you want to use another http verb, pass it explicitly.
Logging in a user
To log in a user before making a request, add the --user
and pass it a user id.
Alternatively, you can also pass an email address to the user
option.
Showing the headers of the response
By default, the visit
command will not show any headers. To display them, add the --headers
option
Following redirects
By default, the visit
command will not follow redirects. To follow redirects and display the response of the redirection target, add the --follow-redirects
option.
Showing exception pages
When your application responds with an exception, the visit
command will show the html of the error page.
To let the visit
command display the actual exception, use the --show-exception
option.
Only displaying the response
If you want the visit
command to only display the response, omitting the response result block at the end, pass the --only-response
option.
Only displaying the response properties block
To avoid displaying the response, and only display the response result block, use the --only-stats
option
Avoid colorizing the response
The visit
command will automatically colorize any HTML and JSON output. To avoid the output being colorized, use the --no-color
option.
Displaying the result HTML as text
Usually an HTML response is quite lengthy. This can make it hard to quickly see what text will be displayed in the browser. To convert an HTML to a text variant, you can pass the --text
option.
This is how the default Laravel homepage will look like.
Filtering HTML output
If you only want to see a part of an HTML response you can use the --filter
option. For HTML output, you can pass a css selector.
Imagine that your app's full response is this HTML:
This command ...
... will display:
Filtering JSON output
If you only want to see a part of an JSON response you can use the --filter
option. You may use dot-notation to reach nested parts.
Imagine that your app's full response is this JSON:
This command ...
... will display:
Adding stats
In the results block underneath the response, you'll see a few interesting stats by default, such as the response time and queries executed.
You can add more stats there by creating your own Stat
class. A valid Stat
is any class that extends Spatie\Visit\Stats\Stat
.
Here's how that base class looks like:
As an example implementation, take a look at the RunTimeStat
that ships with the package.
To activate a Stat
, you should add its class name to the stats
key of the visit
config file.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Freek Van der Herten
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-visit with dependencies
illuminate/contracts Version ^9.0|^10.0|^11.0
nunomaduro/termwind Version ^2.0
soundasleep/html2text Version ^2.0
spatie/laravel-package-tools Version ^1.11.1
symfony/css-selector Version ^6.0
symfony/dom-crawler Version ^6.0
symfony/stopwatch Version ^6.0