PACKAGE IS DEVELOPMENT, DO NOT USE (YET)
This tool can display the response of any URL. Think of it as curl
for humans. By default, the output will be colorized, and the response code and response time will be displayed.
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.
You can install the package via composer:
composer global require spatie/visit
To visit a certain page, execute visit
followed by a URL.
visit spatie.be
By default, the visit
command will make GET request. To use a different HTTP verb, you can pass it to the method
option.
visit <your-url> --method=delete
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.
php artisan visit /my-page --follow-redirects
You can pass a payload to non-GET request by using the payload. The payload should be formatted as JSON.
visit <your-url> --method=post --payload='{"testKey":"testValue"}'
By default, visit
will not show any headers. To display them, add the --headers
option
visit <your-url> /my-page --headers
If you want visit
to only display the response, omitting the response result block at the end, pass the --only-response
option.
visit <your-url> --only-response
To avoid displaying the response, and only display the response result block, use the --only-stats
option
visit <your-url> --only-stats
visit
will automatically colorize any HTML and JSON output. To avoid the output being colorized, use the --no-color
option.
visit <your-url> --no-color
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.
visit <your-url> --text
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:
<html>
<body>
<div>First div</div>
<p>First paragraph</p>
<p>Second paragraph</p>
</body>
</html>
This command ...
visit <your-url> --filter="p"
... will display:
<p>First paragraph</p>
<p>Second paragraph</p>
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:
{
"firstName": "firstValue",
"nested": {
"secondName": "secondValue"
}
}
This command ...
visit <your-url> --filter="nested.secondName"
... will display:
secondValue
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.