Phar archive no read and write permissions with symfony filesystem

前端 未结 1 1813
悲&欢浪女
悲&欢浪女 2021-01-27 15:26

i have created a cli app which tries to create a file with symfony 3 fileSystem component. All works fine, but if i put the app in a phar archive symfony can\'t write the file.<

相关标签:
1条回答
  • 2021-01-27 16:07

    Phar's have a different path structure, and that symfony method does dirname($filename); https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Filesystem/Filesystem.php#L679

    Try defining the full path.

    $path = '.';
    if (!empty($pharPath = \Phar::running(false))) {
        $path = dirname($pharPath);
    } 
    
    $this->fileSystem->dumpFile(
        $path.'/testfile.txt',
        'my test content'
    );
    
    0 讨论(0)
提交回复
热议问题