public static function writeConfigFile($configFile, $plugins, $root = null)
    {
        $root = $root ?: dirname(dirname($configFile));

        $data = [];
        foreach ($plugins as $name => $pluginPath) {
            // Normalize to *nix paths.
            $pluginPath = str_replace('\\', '/', $pluginPath);
            $pluginPath .= '/';

            $pluginPath = str_replace(
                DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR,
                DIRECTORY_SEPARATOR,
                $pluginPath
            );

            // Namespaced plugins should use /
            $name = str_replace('\\', '/', $name);

            $data[] = sprintf("        '%s' => '%s'", $name, $pluginPath);
        }

        $data = implode(",\n", $data);

        $contents = <<<'PHP'
<?php
$baseDir = dirname(dirname(__file__));
return [
    'plugins' => [
%s
    ]
];
PHP;
        $contents = sprintf($contents, $data);

        // Gross hacks to work around composer smashing `__FILE__` in this
        // PHP file when it runs the code through eval()
        $uppercase = function ($matches) {
            return strtoupper($matches[0]);
        };
        $contents = preg_replace_callback('/__file__/', $uppercase, $contents);

        $root = str_replace(
            DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR,
            DIRECTORY_SEPARATOR,
            $root
        );

        // Normalize to *nix paths.
        $root = str_replace('\\', '/', $root);
        $contents = str_replace('\'' . $root, '$baseDir . \'', $contents);

        file_put_contents($configFile, $contents);
    }
public static function writeConfigFile($configFile, $plugins, $root = null)
    {
        $root = $root ?: dirname(dirname($configFile));

        $data = [];
        foreach ($plugins as $name => $pluginPath) {
            // Normalize to *nix paths.
            $pluginPath = str_replace('\\', '/', $pluginPath);
            $pluginPath .= '/';

            $pluginPath = str_replace(
                DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR,
                DIRECTORY_SEPARATOR,
                $pluginPath
            );

            // Namespaced plugins should use /
            $name = str_replace('\\', '/', $name);

            $data[] = sprintf("        '%s' => '%s'", $name, $pluginPath);
        }

        $data = implode(",\n", $data);

        $contents = <<<'PHP'
<?php
$baseDir = dirname(dirname(__file__));
return [
    'plugins' => [
%s
    ]
];
PHP;
        $contents = sprintf($contents, $data);

        // Gross hacks to work around composer smashing `__FILE__` in this
        // PHP file when it runs the code through eval()
        $uppercase = function ($matches) {
            return strtoupper($matches[0]);
        };
        $contents = preg_replace_callback('/__file__/', $uppercase, $contents);

        $root = str_replace(
            DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR,
            DIRECTORY_SEPARATOR,
            $root
        );

        // Normalize to *nix paths.
        $root = str_replace('\\', '/', $root);
        $contents = str_replace('\'' . $root, '$baseDir . \'', $contents);

        file_put_contents($configFile, $contents);
    }
public static function writeConfigFile ( $ configFile , $ plugins , $ root = null ) { $ root = $ root ? : dirname ( dirname ( $ configFile ) ) ; $ data = [ ] ; foreach ( $ plugins as $ name => $ pluginPath ) { // Normalize to *nix paths. $ pluginPath = str_replace ( '\\' , '/' , $ pluginPath ) ; $ pluginPath .= '/' ; $ pluginPath = str_replace ( DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR , DIRECTORY_SEPARATOR , $ pluginPath ) ; // Namespaced plugins should use / $ name = str_replace ( '\\' , '/' , $ name ) ; $ data [ ] = sprintf ( "        '%s' => '%s'" , $ name , $ pluginPath ) ; } $ data = implode ( ",\n" , $ data ) ; $ contents =  <<<'PHP'
<?php
$baseDir = dirname(dirname(__file__));
return [
    'plugins' => [
%s
    ]
];
PHP ; $ contents = sprintf ( $ contents , $ data ) ; // Gross hacks to work around composer smashing `__FILE__` in this // PHP file when it runs the code through eval() $ uppercase = function ( $ matches ) { return strtoupper ( $ matches [ 0 ] ) ; } ; $ contents = preg_replace_callback ( '/__file__/' , $ uppercase , $ contents ) ; $ root = str_replace ( DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR , DIRECTORY_SEPARATOR , $ root ) ; // Normalize to *nix paths. $ root = str_replace ( '\\' , '/' , $ root ) ; $ contents = str_replace ( '\'' . $ root , '$baseDir . \'' , $ contents ) ; file_put_contents ( $ configFile , $ contents ) ; }
Rewrite the config file with a complete list of plugins.

@param string $configFile The path to the config file.
@param array $plugins Of plugins.
@param string|null $root The root directory. Defaults to a value generated from $configFile.

@return void
Rewrite the config file with a complete list of plugins .