generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48c5257
commit aa534c4
Showing
2 changed files
with
106 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,22 @@ | |
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/spatie/laravel-visit/Check%20&%20fix%20styling?label=code%20style)](https://github.com/spatie/laravel-visit/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain) | ||
[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-visit.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-visit) | ||
|
||
This package contains an artisan command `visit` that allows you to 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. | ||
|
||
```bash | ||
php artisan /my-page | ||
``` | ||
|
||
The command display the colorized version of the HTML... | ||
|
||
![screenshot](TODO: add screenshot) | ||
|
||
... followed by a results block. | ||
|
||
![screenshot](TODO: add screenshot) | ||
|
||
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. | ||
|
||
## Support us | ||
|
||
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/laravel-visit.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/laravel-visit) | ||
|
@@ -26,12 +41,96 @@ composer require spatie/laravel-visit | |
|
||
## Usage | ||
|
||
More detailed instructions coming soon. | ||
To visit a certain page, execute `php artisan` followed by a URL. | ||
|
||
```bash | ||
php artisan visit /your-page | ||
``` | ||
|
||
![screenshot](TODO: add screenshot) | ||
|
||
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". | ||
|
||
```bash | ||
php artisan visit --route=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. | ||
|
||
```bash | ||
php artisan visit /users/1 --method=delete | ||
``` | ||
|
||
### Passing a payload | ||
|
||
You can pass a payload to non-GET request by using the payload. The payload should be formatted as JSON. | ||
|
||
```bash | ||
php artisan visit /users --method=post --payload="{name: 'John Doe'}" | ||
``` | ||
|
||
### Logging in a user | ||
|
||
To log in a user before making a request, add the `--user` and pass it a user id. | ||
|
||
```php | ||
php artisan visit /api/user/me --user=1 | ||
``` | ||
|
||
Alternatively, you can also pass an email address to the `user` option. | ||
|
||
```php | ||
php artisan visit /api/user/me [email protected] | ||
``` | ||
|
||
### Showing the headers of the response | ||
|
||
By default, the `visit` command will not show any headers. To display them, add the `--show-headers` option | ||
|
||
```bash | ||
php artisan visit /my-page --show-headers | ||
``` | ||
|
||
![screenshot](TODO: add screenshot) | ||
|
||
### Showing exception pages | ||
|
||
When your application responds with an exception, the `visit` command will show that exception message and not the HTML of your error page. | ||
|
||
To let the `visit` command display the HTML of an error page when an exception occurs, use the `--handle-exceptions` option. | ||
|
||
```bash | ||
php artisan visit /page-with-exception --handle-exceptions | ||
``` | ||
|
||
### 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. | ||
|
||
```bash | ||
php artisan visit / --only-response | ||
``` | ||
|
||
### Only displaying the response properties block | ||
|
||
To avoid displaying the response, and only display the response result block, use the `--only-response-properties` option | ||
|
||
```bash | ||
php artisan visit / --only-response-properties | ||
``` | ||
|
||
### 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. | ||
|
||
```bash | ||
php artisan visit / --no-color | ||
``` | ||
|
||
|
||
|
||
## Testing | ||
|
||
```bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters