Helix Core is now P4 and Helix Swarm is now P4 Code Review. Learn more >>

Documentation | 2025.2

# Environment

This section describes the environment configuration items available for P4 Code Review:

- mode: whether P4 Code Review operates in production or development mode.
- hostname: specifies the canonical hostname P4 Code Review should use, such as in links to P4 Code Review in email notifications.
- external_url: specifies the canonical URL P4 Code Review should use, such as in links to P4 Code Review in email notifications and in test callback URLs. P4 Code Review can often auto-detect the correct URL, but use of `external_url` might be necessary in complex web hosting environments.
- base_url: specifies the folder name P4 Code Review is installed within when P4 Code Review is not installed in the web server's document root.
- logout_url: specifies the URL that users are redirected to when they logout of P4 Code Review.
- emoji_path: specifies the location the Gemoji images are stored in.

If you make a configuration change, P4 Code Review will not use it until the configuration cache has been reloaded, this forces P4 Code Review to use the new configuration. You must be an admin or super user to reload the P4 Code Review config cache. Navigate to the User id dropdown menu, select System Information, click the Cache Info tab, and click the Reload Configuration button.

Add the following configuration block to the `SWARM_ROOT/data/config.php` file:

    <?php
        // this block should be a peer of 'p4'
        'environment' => array(
            'mode'         => 'development',      // defaults to 'production'
            'hostname'     => 'myswarm.hostname', // defaults to requested hostname
            'external_url' => null,               // defaults to null
            'base_url'     => null,               // defaults to null
            'logout_url'   => null,               // defaults to null
            'vendor'       => array(
                'emoji_path' => 'vendor/gemoji/images',
            ),
        ),

## mode

By default, P4 Code Review operates in production mode. When `mode` is set to `development`, P4 Code Review displays greater error detail in the browser. Also, P4 Code Review switches from including aggregated and minified JavaScript and CSS to requesting each JavaScript and CSS resource for all active modules. The default value is production. Any value other than `development` is assumed to mean production.

development mode makes it easier to discover problems and to identify their source, but also incurs additional browser overhead due to many more JavaScript and CSS requests for larger files. We recommend that you do not use development mode in production environments, unless directed to do so by Perforce technical support.

## hostname

The hostname item allows you to specify P4 Code Review's hostname. This could be useful if you have multiple virtual hosts deployed for a single P4 Code Review instance; P4 Code Review uses the hostname you configure when generating its web pages and email notifications.

The value specified for the hostname item should be just the hostname. It should not include a scheme (e.g. `"http://"`), nor should it include a port (e.g. `":80"`).

## external_url

The `external_url` item allows you to specify P4 Code Review's canonical URL. This is useful if your P4 Code Review instance is proxied behind another web service, such as a load balancer, caching proxy, etc., because P4 Code Review's auto-detection of the current hostname or port could otherwise result in incorrect self-referencing URLs.

When specified, P4 Code Review uses the `external_url` item as the prefix for any URLs it creates that link to itself in its web pages, email notifications, and test callback URLs.

- Any path components included in external_url are ignored. If you specify `https://myswarm.url:8080/a/b/c`, P4 Code Review only uses `https://myswarm.url:8080/` when composing URLs.

- If you set the external_url for P4 Code Review, disable the auto_register_url feature in P4 Code Review. For information about disabling the auto_register_url feature for P4 Code Review, see Client integration.

Multiple P4 Code Review instances connected to a single P4 Server instance:

If you specify base_url along with external_url, ensure that all P4 Code Review instances specify the same `base_url`. Varying `base_url` amongst cooperating P4 Code Review instances is not supported.

## base_url

The `base_url` item allows you to specify P4 Code Review's folder within the web server's document root. This is useful if you cannot configure P4 Code Review to operate within its own virtual host, such as when you have an existing web service and P4 Code Review must exist alongside other applications or content. For information on configuring P4 Code Review to run within a sub-folder of an existing website, see Run P4 Code Review in a sub-folder of an existing web site.

The swarm-trigger.conf file must be updated to include the base_url in the SWARM_HOST path, see P4 Code Review trigger configuration

By default, `base_url` is null, which is equivalent to specifying `/`. If you specify a folder, include the leading `/`. For example, `/swarm`.

Multiple P4 Server instances on a single P4 Code Review instance:

Issue: P4 Code Review will lose connection to all of the P4 Servers if you edit the base_url configurable value in the environment block of <swarm_root>/data/config.php. This will stop your system working.

Fix: Remove the base_url configurable from the environment block of <swarm_root>/data/config.php.

Multiple P4 Code Review instances connected to a single P4 Server instance:

If you specify `external_url` along with `base_url`, ensure that all P4 Code Review instances specify the same `base_url`. Varying `base_url` amongst cooperating P4 Code Review instances is not supported.

## logout_url

The logout_url configurable is used to automatically redirect users to a custom URL after they have logged out of P4 Code Review.

When the logout_url item is set and you log out of P4 Code Review:

- Using Log out from P4 Code Review: you are logged out by P4 Code Review and then redirected to the custom URL.
- Using Log out from a single P4 Code Review instance on the global dashboard: you are logged out of the P4 Server instance by P4 Code Review. You are only redirected to the custom URL if you are not logged in to any other P4 Server instances on the global dashboard.
- Using Log out from all instances on the global dashboard: you are logged out of all of the P4 Server instances by P4 Code Review and then redirected to the custom URL.

To redirect users to a custom URL after they have logged out of P4 Code Review, edit the `SWARM_ROOT/data/config.php` file and set the logout_url configurable to the URL you want to redirect users to:

    <?php
        // this block should be a peer of 'p4'
        'environment' => array(
            'logout_url'   => <http[s]://your/redirect/logout/url>, // defaults to null
        ),

The default value is null, users are not redirected when they log out of P4 Code Review.

## emoji_path

The emoji_path configurable defines the location of the Gemoji images in `SWARM_ROOT/public/`.

To change the location of the Gemoji images, edit the `SWARM_ROOT/data/config.php` file and set the emoji_path configurable to the location the Gemoji images are stored in:

    <?php
        // this block should be a peer of 'p4'
        'environment' => array(
            'vendor'   => array(
                'emoji_path' => 'vendor/gemoji/images',
            ),
        ),

The default location is vendor/gemoji/images, this means that by default images are stored in `SWARM_ROOT/public/vendor/gemoji/images`.

### Further information

For instructions on downloading Gemoji and configuring P4 Code Review to use the images, see Emoji.

Your search for returned results