> ## Documentation Index
> Fetch the complete documentation index at: https://nightwatch.laravel.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Start Guide

> Get started with Laravel Nightwatch

<Frame>
  <img src="https://mintcdn.com/nightwatch/bPQ1EOmJXp2EHmh9/images/nightwatch-ui.png?fit=max&auto=format&n=bPQ1EOmJXp2EHmh9&q=85&s=1a5f46e2c8872121d4fd06d6123e807c" alt="Nightwatch UI" width="3006" height="1532" data-path="images/nightwatch-ui.png" />
</Frame>

Welcome to Nightwatch. This guide will help you set up Nightwatch monitoring for your Laravel application in just a few minutes.

## Registering an account

Visit [nightwatch.laravel.com](https://nightwatch.laravel.com) and register for a free account.

After registering, you'll be redirected to the organization creation page. From here, you can create a new organization or join an existing one if you have a pending invite.

## Creating an organization

<Frame>
  <img src="https://mintcdn.com/nightwatch/02NoV2LztE-UZL21/images/createorg.png?fit=max&auto=format&n=02NoV2LztE-UZL21&q=85&s=4f86c5d5e67813907cf56cfcbe4666d0" alt="Create Organization" title="" style={{ width: "100%" }} width="2255" height="1149" data-path="images/createorg.png" />
</Frame>

For a free account, you can get started with as little as an organization name. You can always upgrade and add more details later.

<Info>
  If you're joining an existing organization, you'll need to ask the owner to
  invite you.
</Info>

## Creating an application

<Steps>
  <Step title="Access your dashboard">
    Go to [nightwatch.laravel.com](https://nightwatch.laravel.com) and log in to your account.
  </Step>

  <Step title="Create a new application">
    Click **+ New Application** and provide the following:

    * A name for your application
    * A data region (US, EU or Australia)
    * Details for your default environment (e.g. name, type)
  </Step>

  <Step title="Get your environment token">
    Once your application and its first environment are created, you’ll receive an environment-specific token. This token is required to authenticate the agent and send data to Nightwatch.

    <Info>
      You can retrieve this token anytime from the **Environments** tab in your application settings.
    </Info>
  </Step>
</Steps>

## Running the agent

<Steps>
  <Step title="Install the package">
    Add Nightwatch to your Laravel application using [Composer](https://getcomposer.org/):

    ```bash theme={null}
    composer require laravel/nightwatch
    ```
  </Step>

  <Step title="Add your token">
    Add your environment's `NIGHTWATCH_TOKEN` to your `.env` file:

    ```
    NIGHTWATCH_TOKEN=your-api-key
    ```
  </Step>

  <Step title="Run the agent">
    The agent must be actively running to collect and send data to Nightwatch. Start the agent using the following Artisan command:

    ```bash theme={null}
    php artisan nightwatch:agent
    ```

    <AccordionGroup>
      <Accordion title="Adding a process monitor">
        We strongly recommend using a process monitor to ensure the agent stays running in the background. We've created guides for [Laravel Cloud](/guides/cloud), [Laravel Forge](/guides/forge), [Laravel Vapor](/guides/vapor), [Docker](/guides/docker), and [other providers](/guides/other-providers) to help you get started.
      </Accordion>

      <Accordion title="Monitoring agent health">
        To monitor the health of the running agent, you may run the `php artisan
                        nightwatch:status` command to ensure the agent is able to accept connections.
        The status command will exit with a non-zero status code in the event of an
        error.
      </Accordion>

      <Accordion title="Monitoring multiple apps on a single server">
        If you’re hosting multiple Laravel applications on a single server, you may want to monitor each one independently with Nightwatch.

        The Nightwatch agent process is designed to monitor a single Laravel application in isolation. To monitor multiple applications on the same server, you’ll need to run a separate agent process for each one, with each agent listening on its own port.

        By default, the agent listens on port `2407`. For each additional agent, you will need to set a different port by updating the `NIGHTWATCH_INGEST_URI` in your `.env` file and using the matching `--listen-on` flag when starting the agent.

        ```bash theme={null}
        # App 1 - /var/www/app-1
        NIGHTWATCH_INGEST_URI=127.0.0.1:2407
        php artisan nightwatch:agent --listen-on=127.0.0.1:2407

        # App 2 - /var/www/app-2
        NIGHTWATCH_INGEST_URI=127.0.0.1:2408
        php artisan nightwatch:agent --listen-on=127.0.0.1:2408
        ```

        <Tip>
          Laravel Forge handles this multi-site scenario automatically when using the
          [official
          integration](/guides/forge#automatic-integration-recommended).
        </Tip>
      </Accordion>
    </AccordionGroup>
  </Step>
</Steps>

## Verify your connection

After the agent has been running for a few minutes, you will see your data appear in the Nightwatch dashboard.

<Frame>
  <img src="https://mintcdn.com/nightwatch/02NoV2LztE-UZL21/images/connectedagent.png?fit=max&auto=format&n=02NoV2LztE-UZL21&q=85&s=83d9702688e2a5cc89c8293bef41320c" alt="Connected Agent" width="2255" height="1149" data-path="images/connectedagent.png" />
</Frame>

## Disabling Nightwatch

By default, the Nightwatch package will start monitoring your application once installed. You may wish to disable Nightwatch during local development, your test suite runs, or temporarily in other environments.

You may disable Nightwatch at any time by setting `NIGHTWATCH_ENABLED=false` in your environment. The easiest way to do that for local development and your local test suite runs is to set it in your project's `.env` file:

```sh .env theme={null}
NIGHTWATCH_TOKEN=your-api-key
NIGHTWATCH_ENABLED=false # [!code ++]
```

To ensure Nightwatch is disabled wherever you run your tests, you may also want to disable Nightwatch in your `phpunit.xml` file:

```xml phpunit.xml theme={null}
<?xml version="1.0" encoding="UTF-8"?>
<phpunit>
    <!-- ... -->
    <php>
        <env name="APP_ENV" value="testing"/>
        <env name="NIGHTWATCH_ENABLED" value="false"/> // [!code ++]
        <!-- ... -->
    </php>
</phpunit>
```

## Support

Need help? Visit our [support page](/support) for more information.
