September 7, 2016 Javier Eguiluz

The Filesystem component is a small package that provides convenient utilities for common file system operations. It also abstracts the different behavior of operating systems for some of those file system functions.

In Symfony 3.2 we improved it adding two new functions.

Added a cross-platform readlink() method¶ Contributed by

Titouan Galopin

in #17498. PHP's readlink() function returns the target of a symbolic link. However, its behavior is completely different under Windows and Unix. On Windows systems, readlink() resolves recursively the children links of a link until a final target is found. On Unix-based systems readlink() only resolves the next link. The new readlink() provided by the Filesystem component always behaves in the same way: 1 public function readlink ( $path , $canonicalize = false ) When $canonicalize is false : if $path does not exist or is not a link, it returns null .

does not exist or is not a link, it returns . if $path is a link, it returns the next direct target of the link without considering the existence of the target. When $canonicalize is true : if $path does not exist, it returns null .

does not exist, it returns . if $path exists, it returns its absolute fully resolved final version.