-
Notifications
You must be signed in to change notification settings - Fork 314
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.
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.
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.
PsySH config files are PHP, so you can do pretty much anything you want in there.
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.
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.
It is definitely possible that we'll require your config files multiple times in the same PHP session (for example, if you set two breakpoints in one request, and we launch the shell twice).
If your config files define constants, functions or classes, or require other files, make sure they do those things at most once.
<?php
require_once __DIR__ . '/helpers.php'; // require_once works great here :)
if (\function_exists('somethingAwesome') {
function somethingAwesome()
{
echo 'DO SOMETHING AWESOME!';
}
}