Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/DependencyInjection/ContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@
use function count;
use function dirname;
use function extension_loaded;
use function get_cfg_var;
use function getenv;
use function ini_get;
use function is_array;
use function is_file;
use function is_readable;
use function is_string;
use function spl_object_id;
use function sprintf;
use function str_ends_with;
use function strtr;
use function substr;

/**
Expand Down Expand Up @@ -149,6 +152,12 @@ public function create(

$configurator->setAllConfigFiles($allConfigFiles);

if (!array_key_exists('editorUrl', $projectConfig['parameters'])) {
$configurator->addParameters([
'editorUrl' => $this->getEditorUrlFromPhpIni(),
]);
}

$container = $configurator->createContainer()->getByType(Container::class);
$this->validateParameters($container->getParameters(), $projectConfig['parametersSchema']);
self::postInitializeContainer($container);
Expand Down Expand Up @@ -391,4 +400,23 @@ private function processArgument($argument, bool $required = true)
return $argument;
}

/**
* Try to fetch an editor URL from php.ini by reading xdebug configuration.
*
* This works even if the xdebug extension is not loaded.
*/
private function getEditorUrlFromPhpIni(): ?string
{
$xdebugFileLinkFormat = ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');

if (is_string($xdebugFileLinkFormat) && $xdebugFileLinkFormat !== '') {
return strtr($xdebugFileLinkFormat, [
'%f' => '%file%',
'%l' => '%line%',
]);
}

return null;
}

}
Loading