PHPackages                             spatie/laravel-visit - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. spatie/laravel-visit

ActiveLibrary[Testing &amp; Quality](/categories/testing)

spatie/laravel-visit
====================

Quickly visit any route of your Laravel app

2.0.0(2mo ago)15614.6k↓23.2%9[1 PRs](https://github.com/spatie/laravel-visit/pulls)MITPHPPHP ^8.3CI passing

Since Feb 16Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/spatie/laravel-visit)[ Packagist](https://packagist.org/packages/spatie/laravel-visit)[ Docs](https://github.com/spatie/laravel-visit)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/spatie-laravel-visit/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (32)Versions (15)Used By (0)

Quickly visit any route of your Laravel app
===========================================

[](#quickly-visit-any-route-of-your-laravel-app)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c6a7b1564aa7f56f03f4c4d3e94964474226b475b46eaa32d4598fe9cf665873/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d76697369742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-visit)[![GitHub Tests Action Status](https://camo.githubusercontent.com/e424c80eac6a345c8407a78b056ee45e9ad6a6ca5368eac539ab658604fabbad/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d76697369742f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/spatie/laravel-visit/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/8b0661973c366b7e5c306cec18844646fec4d90fcc01726d2f05474f31f5fbdd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d76697369742f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/spatie/laravel-visit/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/e6dbc6413543d3c1fc4f0f8c464a345e19ae08661cdb5b7aec2dd7978327a437/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d76697369742e7376673f7374796c653d666c61742d737175617265)](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.

```
php artisan visit /my-page
```

The command display the colorized version of the HTML...

[![screenshot](https://camo.githubusercontent.com/0b351d77dfde4ad784d23add5847285e5b52b88a7fbca256fe5ebfff8476d2b3/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d76697369742f696d616765732f68746d6c2e706e67)](https://camo.githubusercontent.com/0b351d77dfde4ad784d23add5847285e5b52b88a7fbca256fe5ebfff8476d2b3/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d76697369742f696d616765732f68746d6c2e706e67)

... followed by a results block.

[![screenshot](https://camo.githubusercontent.com/d9f93dedd3b58caaa46e62880a38e3627d61645c19c2a1931cbd9b865b7360c6/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d76697369742f696d616765732f726573756c74732e706e67)](https://camo.githubusercontent.com/d9f93dedd3b58caaa46e62880a38e3627d61645c19c2a1931cbd9b865b7360c6/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d76697369742f696d616765732f726573756c74732e706e67)

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
-------------------------------------

[](#want-to-use-visit-to-visit-any-site)

[The `spatie/visit` tool](https://github.com/spatie/visit) can be installed globally to visit any site.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/b61b5b52ea444fc0b01b33d024f1ea4e0fd1333705fdf489fef894a2034fdd17/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d76697369742e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-visit)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

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](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require spatie/laravel-visit
```

To colorize HTML, you should install `bat`.

```
brew install bat
```

To colorize JSON, you should install `jq`.

```
brew install jq
```

Optionally, you can publish the config file.

```
php artisan vendor:publish --tag="visit-config"
```

This is the content of the published config file:

```
return [
    /*
     * These classes are responsible for colorizing the output.
     */
    'colorizers' => [
        Spatie\Visit\Colorizers\JsonColorizer::class,
        Spatie\Visit\Colorizers\HtmlColorizer::class,
    ],

    /*
     * These stats will be displayed in the response block.
     */
    'stats' => [
        ...Spatie\Visit\Stats\DefaultStatsClasses::all(),
    ]
];
```

Usage
-----

[](#usage)

To visit a certain page, execute `php artisan` followed by a URL.

```
php artisan visit /your-page
```

[![screenshot](https://camo.githubusercontent.com/0b351d77dfde4ad784d23add5847285e5b52b88a7fbca256fe5ebfff8476d2b3/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d76697369742f696d616765732f68746d6c2e706e67)](https://camo.githubusercontent.com/0b351d77dfde4ad784d23add5847285e5b52b88a7fbca256fe5ebfff8476d2b3/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d76697369742f696d616765732f68746d6c2e706e67)

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".

```
php artisan visit --route=contact
```

### Using a different method

[](#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.

```
php artisan visit /users/1 --method=delete
```

### Passing a payload

[](#passing-a-payload)

You can pass a payload to non-GET request by using the payload. The payload should be formatted as JSON.

```
php artisan visit /users --method=post --payload='{"testKey":"testValue"}'
```

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.

```
visit  --method=patch --payload='{"testKey":"testValue"}'
```

### Logging in a user

[](#logging-in-a-user)

To log in a user before making a request, add the `--user` and pass it a user id.

```
php artisan visit /api/user/me --user=1
```

Alternatively, you can also pass an email address to the `user` option.

```
php artisan visit /api/user/me --user=john@example.com
```

### Showing the headers of the response

[](#showing-the-headers-of-the-response)

By default, the `visit` command will not show any headers. To display them, add the `--headers` option

```
php artisan visit /my-page --headers
```

[![screenshot](https://camo.githubusercontent.com/e812460281bfdbfa030b7de5b8ac94bcc1b20a1fc645a2317369c8765f15cac9/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d76697369742f696d616765732f686561646572732e706e67)](https://camo.githubusercontent.com/e812460281bfdbfa030b7de5b8ac94bcc1b20a1fc645a2317369c8765f15cac9/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d76697369742f696d616765732f686561646572732e706e67)

### Following redirects

[](#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.

```
php artisan visit /my-page --follow-redirects
```

### Showing exception pages

[](#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.

```
php artisan visit /page-with-exception --show-exception
```

### Only displaying the response

[](#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.

```
php artisan visit / --only-response
```

### Only displaying the response properties block

[](#only-displaying-the-response-properties-block)

To avoid displaying the response, and only display the response result block, use the `--only-stats` option

```
php artisan visit / --only-stats
```

### Avoid colorizing the response

[](#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.

```
php artisan visit / --no-color
```

### Displaying the result HTML as text

[](#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.

```
php artisan visit / --text
```

This is how the default Laravel homepage will look like.

[![screenshot](https://camo.githubusercontent.com/924f01196d09b2582f46a48a4afb7eb02462b404b7d6d02f10e58880b2432315/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d76697369742f696d616765732f746578742e706e67)](https://camo.githubusercontent.com/924f01196d09b2582f46a48a4afb7eb02462b404b7d6d02f10e58880b2432315/68747470733a2f2f7370617469652e6769746875622e696f2f6c61726176656c2d76697369742f696d616765732f746578742e706e67)

### Filtering HTML output

[](#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](https://www.w3schools.com/cssref/css_selectors.asp).

Imagine that your app's full response is this HTML:

```

        First div
        First paragraph
        Second paragraph

```

This command ...

```
php artisan visit / --filter="p"
```

... will display:

```
First paragraph
Second paragraph
```

### Filtering JSON output

[](#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:

```
{
    "firstName": "firstValue",
    "nested": {
        "secondName": "secondValue"
    }
}
```

This command ...

```
php artisan visit / --filter="nested.secondName"
```

... will display:

```
secondValue
```

### Adding stats

[](#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:

```
namespace Spatie\Visit\Stats;

use Illuminate\Contracts\Foundation\Application;

abstract class Stat
{
    public function beforeRequest(Application $app)
    {
    }

    public function afterRequest(Application $app)
    {
    }

    abstract public function getStatResult(): StatResult;
}
```

As an example implementation, take a look at the `RunTimeStat` that ships with the package.

```
namespace Spatie\Visit\Stats;

use Illuminate\Contracts\Foundation\Application;
use Symfony\Component\Stopwatch\Stopwatch;
use Symfony\Component\Stopwatch\StopwatchEvent;

class RuntimeStat extends Stat
{
    protected Stopwatch $stopwatch;

    protected ?StopwatchEvent $stopwatchEvent = null;

    public function __construct()
    {
        $this->stopwatch = new Stopwatch(true);
    }

    public function beforeRequest(Application $app)
    {
        $this->stopwatch->start('default');
    }

    public function afterRequest(Application $app)
    {
        $this->stopwatchEvent = $this->stopwatch->stop('default');
    }

    public function getStatResult(): StatResult
    {
        $duration = $this->stopwatchEvent->getDuration();

        return StatResult::make('Duration')
            ->value($duration . 'ms');
    }
}
```

To activate a `Stat`, you should add its class name to the `stats` key of the `visit` config file.

```
// in config/stats.php

return [
    // ...

    'stats' => [
        App\Support\YourCustomStat::class,
        ...Spatie\Visit\Stats\DefaultStatsClasses::all(),
    ]
]
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance88

Actively maintained with recent releases

Popularity42

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 67.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~134 days

Recently: every ~174 days

Total

12

Last Release

77d ago

Major Versions

0.0.3 → 1.0.02022-03-23

1.1.3 → 2.0.02026-03-02

PHP version history (3 changes)0.0.1PHP ^8.0

1.1.2PHP ^8.2

2.0.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (156 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (32 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (25 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (4 commits)")[![timvandijck](https://avatars.githubusercontent.com/u/4528796?v=4)](https://github.com/timvandijck "timvandijck (4 commits)")[![xiCO2k](https://avatars.githubusercontent.com/u/823088?v=4)](https://github.com/xiCO2k "xiCO2k (4 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (2 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (1 commits)")

---

Tags

debuglaravelphproutetestingspatielaravellaravel-visit

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/spatie-laravel-visit/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-laravel-visit/health.svg)](https://phpackages.com/packages/spatie-laravel-visit)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

86910.0M83](/packages/spatie-laravel-health)[spatie/laravel-data

Create unified resources and data transfer objects

1.8k28.9M627](/packages/spatie-laravel-data)[worksome/envy

Automatically keep your .env files in sync.

6871.8M](/packages/worksome-envy)[spatie/laravel-slack-alerts

Send a message to Slack

3212.6M4](/packages/spatie-laravel-slack-alerts)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[spatie/laravel-onboard

A Laravel package to help track user onboarding steps

808342.9k1](/packages/spatie-laravel-onboard)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
