Configuration

Justin Hileman edited this page Jul 9, 2017 · 6 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. The global config.php is loaded first, and the local .psysh.php overrides and extends the global configuration.

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.

Per-project .user.ini files

Support overriding php.ini directives by dropping a .user.ini file in the current directory. Then add a snippet to the top of your config.php.

// Support per-project `php.ini` directive overrides
if (is_file(getcwd() . '/.user.ini')) {
    $conf = parse_ini_file(getcwd() . '/.user.ini');
    foreach ($conf as $key => $val) {
        ini_set($key, $val);
    }
}

Note that, because this is done in userland, only php.ini directives changeable in PHP_INI_ALL or PHP_INI_USER can be set.

More configuration info

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.