Phar example

<?php
$phar = new Phar(__DIR__.\DIRECTORY_SEPARATOR.'deprecation.phar', 0, 'deprecation.phar');
$phar->buildFromDirectory(__DIR__.\DIRECTORY_SEPARATOR.'deprecation');
<?php
$file = __DIR__.'/ProjectWithXsdExtensionInPhar.phar';
if (is_file($file)) {
    @unlink($file);
}

$phar = new Phar($file, 0, 'ProjectWithXsdExtensionInPhar.phar');
$phar->addFromString('ProjectWithXsdExtensionInPhar.php', <<<'EOT' <?php class ProjectWithXsdExtensionInPhar extends ProjectExtension { public function getXsdValidationBasePath(): string { return __DIR__.'/schema'; } public function getNamespace(): string { return 'http://www.example.com/schema/projectwithxsdinphar'; } public function getAlias(): string { return 'projectwithxsdinphar'; } }

        $this->expectException(IOException::class);
        // Skip test if Phar disabled phar.readonly must be 0 in php.ini         if (!\Phar::canWrite()) {
            $this->markTestSkipped('This test cannot run when phar.readonly is 1.');
        }

        $scheme = 'phar://';
        $dirname = $scheme.$this->workspace;
        $pharname = 'foo.phar';

        new \Phar($this->workspace.'/'.$pharname, 0, $pharname);
        // The phar:// stream does not support mode x: fails to create file, errors "failed to open stream: phar error: "$filename" is not a file in phar "$pharname"" and returns false         $this->filesystem->tempnam($dirname$pharname.'/bar');
    }

    public function testTempnamWithHTTPSchemeFails()
    {
        $this->expectException(IOException::class);
        $scheme = 'http://';
        $dirname = $scheme.$this->workspace;

        // The http:// scheme is read-only
Home | Imprint | This part of the site doesn't use cookies.