symlink

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Creates a symbolic link
<?php symlink(string $target, string $link): bool
<?php     public function link($target, $link)

    {

        if (! windows_os()) {

            return symlink($target, $link);

        }



        $mode = $this->isDirectory($target) ? 'J' : 'H';
<?php         $symlink = "{$symlinkDir}/symlink.txt";



        mkdir($symlinkDir);

        symlink($tempFile, $symlink);




        chmod($symlinkDir, 0555);
<?php     {

        $adapter = new LocalFilesystemAdapter(static::ROOT, null, LOCK_EX, LocalFilesystemAdapter::SKIP_LINKS);

        file_put_contents(static::ROOT . '/file.txt', 'content');

        symlink(static::ROOT . '/file.txt', static::ROOT . '/link.txt');




        $contentListing = $adapter->listContents('/', true);
<?php         $this->expectException(SymbolicLinkEncountered::class);

        $adapter = new LocalFilesystemAdapter(static::ROOT, null, LOCK_EX, LocalFilesystemAdapter::DISALLOW_LINKS);

        file_put_contents(static::ROOT . '/file.txt', 'content');

        symlink(static::ROOT . '/file.txt', static::ROOT . '/link.txt');




        $contentListing = $adapter->listContents('/', true);
<?php         mkdir(static::ROOT . '/directory/subdir/', 0744, true);

        $this->assertDirectoryExists(static::ROOT . '/directory/subdir/');

        file_put_contents(static::ROOT . '/directory/subdir/file.txt', 'content');

        symlink(static::ROOT . '/directory/subdir/file.txt', static::ROOT . '/directory/subdir/link.txt');

        $adapter->deleteDirectory('directory/subdir');

        $this->assertDirectoryDoesNotExist(static::ROOT . '/directory/subdir/');

        $adapter->deleteDirectory('directory');
<?php         $externalPath = Path::resolve(base_path('../assets-external'));

        $symlinkPath = base_path('content/assets-linked');



        @symlink($externalPath, $symlinkPath);



        $this->files->put($externalPath.'/statement.txt', 'Change statement.');
<?php         $relativePath = $this->findShortestPath($link, $target);

        chdir(\dirname($link));

        $result = @symlink($relativePath, $link);



        chdir($cwd);
<?php         @mkdir($basepath . "/real", 0777, true);

        touch($basepath . "/real/FILE");



        $result = @symlink($basepath . "/real", $symlinked);



        if (!$result) {

            $this->markTestSkipped('Symbolic links for directories not supported on this platform');
<?php         $symlinked = $this->workingDir . "/linked";

        $symlinkedTrailingSlash = $symlinked . "/";



        $result = @symlink($this->workingDir . "/real", $symlinked);



        if (!$result) {

            $this->markTestSkipped('Symbolic links for directories not supported on this platform');