nur-sery/nur_src/tools/compctl/IdeaProject.php

43 lines
1.1 KiB
PHP

<?php
namespace nur\tools\compctl;
use nur\msg;
class IdeaProject {
const PROJECT_PREFIX = <<<EOT
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PhpServers">
<servers>
<server host="localhost" name="localhost" port="7081" use_path_mappings="true">
<path_mappings>
<mapping local-root="\$PROJECT_DIR\$" remote-root="/var/www/app" />
EOT;
const PROJECT_SUFFIX = <<<EOT
</path_mappings>
</server>
</servers>
</component>
</project>
EOT;
function sync(ConfigFile $config, string $branch, bool $inplace=false): bool {
if ($inplace) return false;
[$deps, $isUrls, $notFoundUrls,
] = $config->getDeps($branch);
if ($deps !== null) {
msg::info("A reporter dans .idea/workspace.xml");
echo self::PROJECT_PREFIX."\n";
foreach ($deps as $dep) {
echo <<<EOT
<mapping local-root="\$PROJECT_DIR$/vendor/$dep[libname]" remote-root="/var/www/$dep[projname]" />
EOT;
echo "\n";
}
echo self::PROJECT_SUFFIX."\n";
}
return false;
}
}