Oihana PHP

createSymlink.php

Table of Contents

Functions

createSymlink()  : bool
Creates a symbolic link pointing to a target.

Functions

Creates a symbolic link pointing to a target.

createSymlink(string $target, string $link[, bool $overwrite = false ]) : bool

The target is not required to exist — dangling symlinks are valid and supported (standard POSIX behaviour). When an entry already exists at $link, it is replaced only if $overwrite is true.

Parameters
$target : string

The path the symlink points to.

$link : string

The symlink path to create.

$overwrite : bool = false

Whether to replace an existing file/symlink at $link (default: false).

throws
FileException

If an entry already exists at $link and $overwrite is false, or if the symlink cannot be created.

author

Marc Alcaraz (ekameleon)

since
1.2.0
example
use function oihana\files\createSymlink;

createSymlink( '/var/www/releases/42' , '/var/www/current' , overwrite: true ) ;
Return values
bool

Returns true on success.

On this page

Search results