Repository navigation
Symbolic links
GT\Sync\SymlinkSync creates a symbolic link from a source path to a destination path.
Use this when one public path should point at another directory or file without needing to copy the contents.
use GT\Sync\SymlinkSync;
$sync = new SymlinkSync(
"data/upload",
"www/data/upload"
);
$sync->exec();If the parent directory for the destination does not exist, it is created.
$sync = new SymlinkSync(
"asset/logo.svg",
"www/logo.svg"
);
$sync->exec();The same class handles both files and directories.
If the destination is already a symbolic link to the same source, the operation is skipped.
If the destination is a symbolic link to a different source, the old link is removed and a new one is created.
If the destination already exists and is not a symbolic link, symlink() fails and the destination path is added to the failed list.
After exec() has run, these methods describe the result:
$linkedFiles = $sync->getLinkedFilesList();
$linkedDirectories = $sync->getLinkedDirectoriesList();
$allLinked = $sync->getCombinedLinkedList();
$skipped = $sync->getSkippedList();
$failed = $sync->getFailedList();Each call to exec() clears the previous lists before trying again.
Next, move on to command line to use the same functionality from the terminal.
PHP.GT/Sync is a separately maintained component of PHP.GT/WebEngine.