Skip to content

Configuration

Justin Hileman edited this page Jun 3, 2017 · 8 revisions

๐Ÿ›  Configuration

While PsySH strives to detect the right settings automatically, you might want to fine-tune the configuration yourself. Add a file to ~/.config/psysh/config.php (or C:\Users\{USER}\AppData\Roaming\PsySH\config.php on Windows):

<?php
return [
    'commands' => [
        new \Psy\Command\ParseCommand,
    ],

    'defaultIncludes' => [
        __DIR__ . '/include/bootstrap.php',
    ],

    'startupMessage' => sprintf('<info>%s</info>', shell_exec('uptime')),
];

See the full list of configuration options and a sample config file for further explanation of the available options.

Per-project config files

When PsySH starts, it checks for a per-project .psysh.php config file in the current directory. Both the global and the local config files are used if they exist, with global config.php being loaded first.

Specifying a different config file

Pass --config PATH when launching PsySH to use a custom config file path. You can specify your config file location in the PSYSH_CONFIG environment variable as well.

ProTipsโ„ข

PsySH config files are PHP, so you can do pretty much anything you want in there.

Automatically load Composer dependencies

Add something like this to the top of your PsySH config:

// Automatically autoload Composer dependencies
if (is_file(getcwd() . '/vendor/autoload.php')) {
    require_once getcwd() . '/vendor/autoload.php';
}

This shouldnโ€™t be necessary if youโ€™ve installed PsySH as a Composer dependency (or dev dependency) for your project. It will already be using the Composer autoloader in that case.

More configuration info