### Get Root Directory with Path::getRoot Source: https://context7.com/symfony/filesystem/llms.txt Returns the root directory of a given path, supporting UNIX, Windows, and stream wrapper roots. ```php makePathRelative( '/var/www/app/public/css/style.css', '/var/www/app/public' ); // Returns: css/style.css/ // Navigate up directories $relative = $filesystem->makePathRelative( '/var/www/shared/assets', '/var/www/app/public' ); // Returns: ../../shared/assets/ ``` -------------------------------- ### Get User Home Directory Source: https://context7.com/symfony/filesystem/llms.txt Retrieve the canonicalized path to the user's home directory using `Path::getHomeDirectory()`. This method throws a `RuntimeException` if the directory cannot be determined. ```php getMessage(); } ``` -------------------------------- ### Filesystem::makePathRelative Source: https://context7.com/symfony/filesystem/llms.txt Given two absolute paths, returns a relative path from the start path to the end path. ```APIDOC ## makePathRelative - Convert to Relative Path ### Description Given two absolute paths, returns a relative path from the start path to the end path. ### Method `makePathRelative` ### Parameters #### Path Parameters - **startPath** (string) - Required - The starting absolute path. - **endPath** (string) - Required - The ending absolute path. ### Request Example ```php use Symfony\Component\Filesystem\Filesystem; $filesystem = new Filesystem(); $relative = $filesystem->makePathRelative('/var/www/app/public/css/style.css', '/var/www/app/public'); $relativeUp = $filesystem->makePathRelative('/var/www/shared/assets', '/var/www/app/public'); ``` ### Response #### Success Response (string) - The relative path from `startPath` to `endPath`. #### Response Example ``` css/style.css/ ../../shared/assets/ ``` ``` -------------------------------- ### Get File Extension in PHP Source: https://context7.com/symfony/filesystem/llms.txt Retrieves the file extension without the leading dot, with an option to force lowercase output. ```php mkdir('/var/www/app/cache'); // Create multiple directories at once $filesystem->mkdir([ '/var/www/app/logs', '/var/www/app/uploads', '/var/www/app/sessions' ]); // Create with specific permissions (octal) $filesystem->mkdir('/var/www/app/private', 0o700); } catch (IOException $e) { echo 'Failed to create directory: ' . $e->getMessage(); echo 'Path: ' . $e->getPath(); } ``` -------------------------------- ### Create Symbolic Links with symlink Source: https://context7.com/symfony/filesystem/llms.txt Creates a symbolic link. On Windows, setting the third parameter to true allows copying the directory instead of creating a link, which avoids the need for admin privileges. ```php symlink('/var/www/shared/assets', '/var/www/app/public/assets'); // On Windows, copy instead of creating symlink (no admin rights needed) $filesystem->symlink('/var/www/shared/assets', '/var/www/app/public/assets', true); } catch (IOException $e) { echo 'Symlink failed: ' . $e->getMessage(); } ``` -------------------------------- ### mirror - Mirror a Directory Source: https://context7.com/symfony/filesystem/llms.txt Copies an entire directory structure to another location with support for overwriting, symlinks, and deletion. ```APIDOC ## mirror ### Description Copies an entire directory structure to another location. Supports options for overwriting, following symlinks, and deleting extra files in target. ### Parameters - **originDir** (string) - Required - The source directory path. - **targetDir** (string) - Required - The destination directory path. - **iterator** (Traversable|null) - Optional - Custom iterator for filtering files. - **options** (array) - Optional - Configuration options: 'override' (bool), 'follow_symlinks' (bool), 'delete' (bool). ``` -------------------------------- ### symlink - Create Symbolic Links Source: https://context7.com/symfony/filesystem/llms.txt Creates a symbolic link. On Windows, it can optionally copy the directory instead. ```APIDOC ## symlink - Create Symbolic Links ### Description Creates a symbolic link. On Windows with `$copyOnWindows` set to true, copies the directory instead (requires admin rights for symlinks). ### Method `symlink` ### Parameters #### Path Parameters - **target** (string) - Required - The target path of the link. - **link** (string) - Required - The path where the link will be created. - **copyOnWindows** (bool) - Optional - If true, copies the directory on Windows instead of creating a symlink. ### Request Example ```php use Symfony\Component\Filesystem\Filesystem; $filesystem = new Filesystem(); $filesystem->symlink('/var/www/shared/assets', '/var/www/app/public/assets'); $filesystem->symlink('/var/www/shared/assets', '/var/www/app/public/assets', true); // On Windows, copy instead ``` ### Response This method does not return a value upon success. Exceptions are thrown on failure. ``` -------------------------------- ### Copy Files with copy Source: https://context7.com/symfony/filesystem/llms.txt Copies files from source to destination, with optional overwriting of newer files and support for remote URLs. ```php copy('/path/to/source.txt', '/path/to/destination.txt'); // Force overwrite even if target is newer $filesystem->copy('/path/to/source.txt', '/path/to/destination.txt', true); // Copy from remote URL $filesystem->copy('https://example.com/file.pdf', '/local/path/file.pdf'); } catch (FileNotFoundException $e) { echo 'Source file not found: ' . $e->getPath(); } catch (IOException $e) { echo 'Copy failed: ' . $e->getMessage(); } ``` -------------------------------- ### Filesystem::tempnam Source: https://context7.com/symfony/filesystem/llms.txt Creates a temporary file with support for custom stream wrappers and suffixes. ```APIDOC ## tempnam - Create Temporary File ### Description Creates a temporary file with support for custom stream wrappers and suffixes. ### Method `tempnam` ### Parameters #### Path Parameters - **dir** (string) - Required - The directory where the temporary file will be created. - **prefix** (string) - Required - The prefix for the temporary file name. - **suffix** (string) - Optional - The suffix for the temporary file name. ### Request Example ```php use Symfony\Component\Filesystem\Filesystem; $filesystem = new Filesystem(); $tempFile = $filesystem->tempnam(sys_get_temp_dir(), 'app_'); $tempFileWithSuffix = $filesystem->tempnam('/var/www/app/cache', 'cache_', '.tmp'); ``` ### Response #### Success Response (string) - The absolute path to the created temporary file. #### Response Example ``` /tmp/app_a1b2c3d4 /var/www/app/cache/cache_a1b2c3d4.tmp ``` ### Error Handling - Throws `IOException` if the file cannot be created. ``` -------------------------------- ### Path::join Source: https://context7.com/symfony/filesystem/llms.txt Joins multiple path strings into a single canonical path. ```APIDOC ## join - Join Path Segments ### Description Joins multiple path strings into a single canonical path. ### Method `Path::join` ### Parameters #### Path Parameters - **segments** (array of strings) - Required - The path segments to join. ### Request Example ```php use Symfony\Component\Filesystem\Path; $joinedPath = Path::join('/var/www', 'app', 'config'); $joinedWithSlashes = Path::join('/var/www/', '/app/', 'config'); $joinedWithDots = Path::join('/var/www', '..', 'app', './config'); $joinedStream = Path::join('phar://', '/app.phar', 'src/file.php'); ``` ### Response #### Success Response (string) - The joined canonical path. #### Response Example ``` /var/www/app/config /var/www/app/config /var/app/config phar:///app.phar/src/file.php ``` ``` -------------------------------- ### Create Temporary File with tempnam Source: https://context7.com/symfony/filesystem/llms.txt Use tempnam to create a temporary file in a specified directory with custom prefixes and suffixes. Handles potential IO exceptions during file creation. ```php tempnam(sys_get_temp_dir(), 'app_'); // Returns: /tmp/app_a1b2c3d4 // Create temp file with specific suffix $tempFile = $filesystem->tempnam('/var/www/app/cache', 'cache_', '.tmp'); // Returns: /var/www/app/cache/cache_a1b2c3d4.tmp // Use the temp file file_put_contents($tempFile, 'temporary data'); // Clean up $filesystem->remove($tempFile); } catch (IOException $e) { echo 'Failed to create temp file: ' . $e->getMessage(); } ``` -------------------------------- ### Atomically Write File Content with dumpFile Source: https://context7.com/symfony/filesystem/llms.txt Writes content to a file atomically by writing to a temporary file first and then renaming it. Parent directories are created automatically if they do not exist. ```php dumpFile('/var/www/app/config/parameters.json', json_encode([ 'database' => 'mysql://localhost/app', 'debug' => false ], JSON_PRETTY_PRINT)); // Write from a stream resource $resource = fopen('php://memory', 'r+'); fwrite($resource, 'Stream content here'); rewind($resource); $filesystem->dumpFile('/path/to/output.txt', $resource); fclose($resource); } catch (IOException $e) { echo 'Failed to write file: ' . $e->getMessage(); } ``` -------------------------------- ### Filesystem Class - copy Source: https://context7.com/symfony/filesystem/llms.txt Copies a file from origin to target. By default, newer target files are not overwritten unless `$overwriteNewerFiles` is set to `true`. ```APIDOC ## POST /filesystem/copy ### Description Copies a file from origin to target. By default, newer target files are not overwritten unless `overwriteNewerFiles` is set to `true`. ### Method POST ### Endpoint /filesystem/copy ### Parameters #### Request Body - **origin** (string) - Required - The path to the source file. - **target** (string) - Required - The path to the destination file. - **overwriteNewerFiles** (boolean) - Optional - If set to `true`, the target file will be overwritten even if it is newer than the origin file. Defaults to `false`. ### Request Example ```json { "origin": "/path/to/source.txt", "target": "/path/to/destination.txt", "overwriteNewerFiles": true } ``` ### Response #### Success Response (200) Indicates successful file copy. #### Response Example ```json { "message": "File copied successfully." } ``` ``` -------------------------------- ### touch - Set File Timestamps Source: https://context7.com/symfony/filesystem/llms.txt Sets access and modification time of files, creating the file if it does not exist. ```APIDOC ## touch ### Description Sets access and modification time of files. Creates the file if it doesn't exist. ### Parameters - **files** (string|iterable) - Required - Path or list of paths to files. - **time** (int) - Optional - Modification time. - **atime** (int) - Optional - Access time. ``` -------------------------------- ### Convert to Relative Path in PHP Source: https://context7.com/symfony/filesystem/llms.txt Calculates the relative path from a base path to a target path. ```php hardlink('/path/to/original.txt', '/path/to/hardlink.txt'); // Create multiple hard links to the same file $filesystem->hardlink('/path/to/original.txt', [ '/path/to/link1.txt', '/path/to/link2.txt', '/path/to/link3.txt' ]); } catch (FileNotFoundException $e) { echo 'Original file not found: ' . $e->getPath(); } catch (IOException $e) { echo 'Hardlink failed: ' . $e->getMessage(); } ``` -------------------------------- ### Path::getHomeDirectory Source: https://context7.com/symfony/filesystem/llms.txt Retrieves the canonicalized path to the current user's home directory. ```APIDOC ## Path::getHomeDirectory ### Description Returns the canonicalized path to the user's home directory. ### Response - **string** - The absolute path to the home directory. ### Errors - **RuntimeException** - Thrown if the home directory cannot be determined. ``` -------------------------------- ### Read File Content with readFile Source: https://context7.com/symfony/filesystem/llms.txt Reads and returns the entire contents of a file as a string. ```php readFile('/var/www/app/config/settings.json'); $settings = json_decode($content, true); // Process content echo 'App name: ' . $settings['app_name']; } catch (IOException $e) { echo 'Failed to read file: ' . $e->getMessage(); } ``` -------------------------------- ### Filesystem Class - exists Source: https://context7.com/symfony/filesystem/llms.txt Checks whether one or more files or directories exist. Returns true only if all specified paths exist. ```APIDOC ## GET /filesystem/exists ### Description Checks whether one or more files or directories exist. Returns `true` only if all specified paths exist. ### Method GET ### Endpoint /filesystem/exists ### Parameters #### Query Parameters - **paths** (array|string) - Required - The path(s) to the file(s) or directory(ies) to check. ### Request Example ``` GET /filesystem/exists?paths[]=/var/www/app/config.php&paths[]=/var/www/app/.env ``` ### Response #### Success Response (200) - **exists** (boolean) - `true` if all specified paths exist, `false` otherwise. #### Response Example ```json { "exists": true } ``` ``` -------------------------------- ### Check File Extension in PHP Source: https://context7.com/symfony/filesystem/llms.txt Verifies if a path contains a specific extension or any extension at all, supporting case-insensitive checks and multiple extension arrays. ```php touch('/var/www/app/cache/.gitkeep'); // Touch multiple files $filesystem->touch(['/path/file1.txt', '/path/file2.txt']); // Set specific modification time $filesystem->touch('/path/to/file.txt', strtotime('2024-01-15')); // Set both modification and access time $modTime = strtotime('2024-01-15'); $accessTime = strtotime('2024-01-20'); $filesystem->touch('/path/to/file.txt', $modTime, $accessTime); } catch (IOException $e) { echo 'Touch failed: ' . $e->getMessage(); } ``` -------------------------------- ### Mirror a Directory Source: https://context7.com/symfony/filesystem/llms.txt Copies directory structures with options for overwriting, symlink handling, and deletion. Supports custom iterators for filtering files. ```php mirror('/source/directory', '/target/directory'); // Mirror with options $filesystem->mirror('/source/directory', '/target/directory', null, [ 'override' => true, // Overwrite newer files in target 'follow_symlinks' => true, // Copy files instead of symlinks (useful on Windows) 'delete' => true // Delete files in target not present in source ]); // Mirror with custom iterator (filter specific files) $iterator = new \RecursiveIteratorIterator( new \RecursiveCallbackFilterIterator( new \RecursiveDirectoryIterator('/source/directory', \FilesystemIterator::SKIP_DOTS), function ($current) { // Only include PHP files return $current->isDir() || $current->getExtension() === 'php'; } ), \RecursiveIteratorIterator::SELF_FIRST ); $filesystem->mirror('/source/directory', '/target/directory', $iterator); } catch (IOException $e) { echo 'Mirror failed: ' . $e->getMessage(); } ``` -------------------------------- ### Normalize Path with Path::canonicalize Source: https://context7.com/symfony/filesystem/llms.txt Normalizes a path by resolving '.' and '..' segments and converting Windows backslashes to forward slashes. Also resolves the home directory '~'. ```php remove('/var/www/app/cache/temp.cache'); // Remove a directory and all its contents $filesystem->remove('/var/www/app/cache'); // Remove multiple items at once $filesystem->remove([ '/var/www/app/logs/old.log', '/var/www/app/cache', '/var/www/app/sessions' ]); } catch (IOException $e) { echo 'Removal failed: ' . $e->getMessage(); } ``` -------------------------------- ### Path::isAbsolute and Path::isRelative Source: https://context7.com/symfony/filesystem/llms.txt Determine whether a path is absolute or relative. ```APIDOC ## Path::isAbsolute / Path::isRelative ### Description Determine whether a path is absolute or relative. ### Parameters #### Arguments - **path** (string) - Required - The path to check. ``` -------------------------------- ### Filesystem Class - remove Source: https://context7.com/symfony/filesystem/llms.txt Removes files, directories, or symbolic links. Directories are removed recursively. ```APIDOC ## DELETE /filesystem/remove ### Description Removes files, directories, or symbolic links. Directories are removed recursively. ### Method DELETE ### Endpoint /filesystem/remove ### Parameters #### Request Body - **paths** (array|string) - Required - The path(s) to the file(s), directory(ies), or symbolic link(s) to remove. ### Request Example ```json { "paths": [ "/var/www/app/cache/temp.cache", "/var/www/app/cache" ] } ``` ### Response #### Success Response (200) Indicates successful removal of files and directories. #### Response Example ```json { "message": "Items removed successfully." } ``` ``` -------------------------------- ### Check Existence with exists Source: https://context7.com/symfony/filesystem/llms.txt Verifies if one or more paths exist. Returns true only if every path provided in the input array is present. ```php exists('/var/www/app/config.php')) { echo 'Config file exists'; } // Check multiple files - returns true only if ALL exist if ($filesystem->exists(['/var/www/app/config.php', '/var/www/app/.env'])) { echo 'Both configuration files exist'; } ``` -------------------------------- ### Path::getExtension Source: https://context7.com/symfony/filesystem/llms.txt Returns the file extension without the leading dot. ```APIDOC ## Path::getExtension ### Description Returns the file extension without the leading dot. ### Parameters #### Arguments - **path** (string) - Required - The file path. - **forceLowercase** (bool) - Optional - Whether to force the extension to lowercase. ``` -------------------------------- ### hardlink - Create Hard Links Source: https://context7.com/symfony/filesystem/llms.txt Creates one or more hard links to a file. Hard links share the same inode and data blocks. ```APIDOC ## hardlink - Create Hard Links ### Description Creates one or more hard links to a file. Hard links share the same inode and data blocks. ### Method `hardlink` ### Parameters #### Path Parameters - **target** (string) - Required - The path to the original file. - **link** (string|array) - Required - The path(s) where the hard link(s) will be created. ### Request Example ```php use Symfony\Component\Filesystem\Filesystem; $filesystem = new Filesystem(); $filesystem->hardlink('/path/to/original.txt', '/path/to/hardlink.txt'); $filesystem->hardlink('/path/to/original.txt', [ '/path/to/link1.txt', '/path/to/link2.txt', '/path/to/link3.txt' ]); ``` ### Response This method does not return a value upon success. Exceptions are thrown on failure. ``` -------------------------------- ### Append Content to File with appendToFile Source: https://context7.com/symfony/filesystem/llms.txt Appends content to an existing file or creates it if missing. Supports optional file locking for concurrent access. ```php appendToFile('/var/log/app.log', "[INFO] Application started\n"); // Append with file locking (for concurrent access) $filesystem->appendToFile('/var/log/app.log', "[DEBUG] Processing request\n", true); // Append from resource $resource = fopen('php://memory', 'r+'); fwrite($resource, 'Additional content'); rewind($resource); $filesystem->appendToFile('/path/to/file.txt', $resource); fclose($resource); } catch (IOException $e) { echo 'Failed to append to file: ' . $e->getMessage(); } ``` -------------------------------- ### Check if Path is Absolute with isAbsolutePath Source: https://context7.com/symfony/filesystem/llms.txt Determines if a given path is absolute, supporting UNIX, Windows, and stream wrapper formats. ```php isAbsolutePath('/var/www/app'); // true (UNIX absolute) $filesystem->isAbsolutePath('C:/Users/app'); // true (Windows absolute) $filesystem->isAbsolutePath('phar:///app.phar'); // true (stream wrapper) $filesystem->isAbsolutePath('relative/path'); // false $filesystem->isAbsolutePath('../parent'); // false ``` -------------------------------- ### dumpFile - Atomically Write File Content Source: https://context7.com/symfony/filesystem/llms.txt Writes content to a file atomically by using a temporary file and then renaming it. Parent directories are created if they do not exist. ```APIDOC ## dumpFile - Atomically Write File Content ### Description Writes content to a file atomically (writes to temp file first, then renames). Creates parent directories if needed. ### Method `dumpFile` ### Parameters #### Path Parameters - **path** (string) - Required - The path to the file where content will be written. - **content** (string|resource) - Required - The content to write to the file. Can be a string or a stream resource. ### Request Example ```php use Symfony\Component\Filesystem\Filesystem; $filesystem = new Filesystem(); $filesystem->dumpFile('/var/www/app/config/parameters.json', json_encode([ 'database' => 'mysql://localhost/app', 'debug' => false ], JSON_PRETTY_PRINT)); $resource = fopen('php://memory', 'r+'); fwrite($resource, 'Stream content here'); rewind($resource); $filesystem->dumpFile('/path/to/output.txt', $resource); fclose($resource); ``` ### Response This method does not return a value upon success. Exceptions are thrown on failure. ``` -------------------------------- ### Rename or Move Files with rename Source: https://context7.com/symfony/filesystem/llms.txt Renames or moves files and directories. Overwriting existing targets requires setting the third parameter to true. ```php rename('/path/to/old-name.txt', '/path/to/new-name.txt'); // Move to different directory $filesystem->rename('/downloads/file.pdf', '/documents/file.pdf'); // Rename with overwrite if target exists $filesystem->rename('/path/to/source.txt', '/path/to/existing.txt', true); } catch (IOException $e) { echo 'Rename failed: ' . $e->getMessage(); } ``` -------------------------------- ### Path::makeAbsolute Source: https://context7.com/symfony/filesystem/llms.txt Converts a relative path to an absolute path based on a given base path. ```APIDOC ## Path::makeAbsolute ### Description Converts a relative path to an absolute path based on a given base path. ### Parameters #### Arguments - **path** (string) - Required - The path to convert. - **basePath** (string) - Required - The base path to use. ``` -------------------------------- ### Read Link Target with readlink Source: https://context7.com/symfony/filesystem/llms.txt Reads the target of a symbolic link. Use the canonicalize option to return the absolute resolved path. ```php readlink('/var/www/app/public/assets'); // Returns: /var/www/shared/assets (or null if not a link) // Get canonicalized absolute path (resolves all symlinks) $realPath = $filesystem->readlink('/var/www/app/public/assets', true); // Returns: /var/www/shared/assets (absolute resolved path, or null if path doesn't exist) ``` -------------------------------- ### Filesystem::isAbsolutePath Source: https://context7.com/symfony/filesystem/llms.txt Returns whether the given path is an absolute path (including URLs and stream wrappers). ```APIDOC ## isAbsolutePath - Check if Path is Absolute ### Description Returns whether the given path is an absolute path (including URLs and stream wrappers). ### Method `isAbsolutePath` ### Parameters #### Path Parameters - **path** (string) - Required - The path to check. ### Request Example ```php use Symfony\Component\Filesystem\Filesystem; $filesystem = new Filesystem(); $isAbsoluteUnix = $filesystem->isAbsolutePath('/var/www/app'); $isAbsoluteWindows = $filesystem->isAbsolutePath('C:/Users/app'); $isAbsoluteStream = $filesystem->isAbsolutePath('phar:///app.phar'); $isRelative = $filesystem->isAbsolutePath('relative/path'); $isRelativeParent = $filesystem->isAbsolutePath('../parent'); ``` ### Response #### Success Response (boolean) - `true` if the path is absolute, `false` otherwise. #### Response Example ``` true true true false false ``` ``` -------------------------------- ### Path::changeExtension Source: https://context7.com/symfony/filesystem/llms.txt Changes the extension of a file path. ```APIDOC ## Path::changeExtension ### Description Changes the extension of a file path. ### Parameters #### Arguments - **path** (string) - Required - The file path. - **extension** (string) - Required - The new extension. ``` -------------------------------- ### readFile - Read File Content Source: https://context7.com/symfony/filesystem/llms.txt Reads and returns the entire contents of a file as a string. ```APIDOC ## readFile - Read File Content ### Description Reads and returns the entire contents of a file as a string. ### Method `readFile` ### Parameters #### Path Parameters - **path** (string) - Required - The path to the file to read. ### Request Example ```php use Symfony\Component\Filesystem\Filesystem; $filesystem = new Filesystem(); $content = $filesystem->readFile('/var/www/app/config/settings.json'); $settings = json_decode($content, true); echo 'App name: ' . $settings['app_name']; ``` ### Response #### Success Response (200) - **content** (string) - The entire content of the file as a string. ``` -------------------------------- ### appendToFile - Append Content to File Source: https://context7.com/symfony/filesystem/llms.txt Appends content to an existing file, creating it if it doesn't exist. Supports file locking for concurrent access. ```APIDOC ## appendToFile - Append Content to File ### Description Appends content to an existing file, creating it if it doesn't exist. Supports file locking. ### Method `appendToFile` ### Parameters #### Path Parameters - **path** (string) - Required - The path to the file to append content to. - **content** (string|resource) - Required - The content to append. Can be a string or a stream resource. - **lock** (bool) - Optional - If true, acquires an exclusive lock on the file before writing. Defaults to false. ### Request Example ```php use Symfony\Component\Filesystem\Filesystem; $filesystem = new Filesystem(); $filesystem->appendToFile('/var/log/app.log', "[INFO] Application started\n"); $filesystem->appendToFile('/var/log/app.log', "[DEBUG] Processing request\n", true); // With file locking $resource = fopen('php://memory', 'r+'); fwrite($resource, 'Additional content'); rewind($resource); $filesystem->appendToFile('/path/to/file.txt', $resource); fclose($resource); ``` ### Response This method does not return a value upon success. Exceptions are thrown on failure. ``` -------------------------------- ### Path::hasExtension Source: https://context7.com/symfony/filesystem/llms.txt Checks if a path has a specific extension or any extension at all. ```APIDOC ## Path::hasExtension ### Description Checks if a path has a specific extension or any extension at all. ### Parameters #### Arguments - **path** (string) - Required - The file path. - **extension** (string|array) - Optional - The extension(s) to check. - **caseInsensitive** (bool) - Optional - Whether the check should be case insensitive. ``` -------------------------------- ### Check Path Type in PHP Source: https://context7.com/symfony/filesystem/llms.txt Determines if a path is absolute or relative, supporting various OS formats and stream wrappers. ```php chmod('/var/www/app/bin/console', 0o755); // Set permissions on multiple files $filesystem->chmod(['/path/script1.sh', '/path/script2.sh'], 0o755); // Apply permissions with umask $filesystem->chmod('/path/to/file', 0o777, 0o022); // Results in 0755 // Recursive chmod on directory $filesystem->chmod('/var/www/app/var', 0o775, 0o000, true); } catch (IOException $e) { echo 'Chmod failed: ' . $e->getMessage(); } ``` -------------------------------- ### Check if Path is Local Source: https://context7.com/symfony/filesystem/llms.txt Use `Path::isLocal()` to determine if a given path refers to the local filesystem, excluding URLs with schemes. ```php readlink('/var/www/app/public/assets'); // Returns: /var/www/shared/assets (or null) $realPath = $filesystem->readlink('/var/www/app/public/assets', true); // Returns: /var/www/shared/assets (absolute resolved path, or null) ``` ### Response #### Success Response (200) - **target** (string|null) - The target path of the symbolic link, or null if the path is not a symbolic link or does not exist. ``` -------------------------------- ### Find Common Base Path in PHP Source: https://context7.com/symfony/filesystem/llms.txt Identifies the longest common directory path shared by multiple provided paths. ```php