当前位置: 首页>>代码示例>>PHP>>正文


PHP FileSystem::normalizePath方法代码示例

本文整理汇总了PHP中FileSystem::normalizePath方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::normalizePath方法的具体用法?PHP FileSystem::normalizePath怎么用?PHP FileSystem::normalizePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileSystem的用法示例。


在下文中一共展示了FileSystem::normalizePath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: savePsr4s

 public static function savePsr4s($vendorDir, $localPsr4Config, $io)
 {
     $filesystem = new FileSystem();
     $psr4File = $filesystem->normalizePath(realpath($vendorDir . self::PSR4_FILE));
     if ($localPsr4Config && $psr4File) {
         $io->write('generating local autoload_psr4.php ....');
         self::appendBeforeLastline($localPsr4Config, $psr4File);
         $io->write('local autoload_psr4 generated.');
     }
 }
开发者ID:jaslin,项目名称:composer-yii2-local-extension-setup-scripts,代码行数:10,代码来源:ComposerScripts.php

示例2: generateFakeAutoloadFile

    /**
     * Generates fake autoload file pointing to real autoload.php
     *
     * @param BasePackage packager
     * @param string target file path
     */
    protected function generateFakeAutoloadFile(BasePackage $package, $targetPath)
    {
        // Prepare paths
        $packageInstallPath = $this->getInstallPath($package);
        $targetDir = $this->fs->normalizePath($packageInstallPath . '/' . dirname($targetPath));
        $targetBasename = basename($targetPath);
        // Create short path to fake autoload file (for display purposes)
        $displayFilePath = $this->fs->findShortestPath($this->getBasePath(), "{$targetDir}/{$targetBasename}");
        // If target directory does not exist, skip
        if (!is_dir($targetDir)) {
            $this->io->write('Skiping generation of fake autoload file: ' . $displayFilePath);
            return;
        }
        // Find relative path from directory of fake autoload file to real autoload.php
        $relativePath = $this->fs->findShortestPath($targetDir, $this->getVendorDirPath(), TRUE);
        $autoloadPath = var_export('/' . rtrim($relativePath, '/') . '/autoload.php', TRUE);
        // Create fake autoload content
        $content = <<<BOOTSTRAP_END
<?php

/**
 * @warning This file is automatically generated by Composer.
 * @see https://github.com/vbuilder/composer-plugin
 */

return include __DIR__ . {$autoloadPath};

BOOTSTRAP_END;
        // Write
        $this->io->write('Generating fake autoload in: ' . $displayFilePath);
        file_put_contents($targetDir . '/' . $targetBasename, $content);
        // Mark file as unchanged for Git
        if (is_dir("{$packageInstallPath}/.git")) {
            $exitCode = $this->process->execute('git --git-dir ' . escapeshellarg("{$packageInstallPath}/.git") . ' --work-tree ' . escapeshellarg($packageInstallPath) . ' update-index --assume-unchanged ' . escapeshellarg($targetPath));
            if ($exitCode) {
                throw new \RuntimeException('Failed to mark ' . $displayFilePath . ' as unchanged');
            }
        }
    }
开发者ID:vbuilder,项目名称:composer-plugin,代码行数:45,代码来源:Plugin.php


注:本文中的FileSystem::normalizePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。