Download the PHP package anteris-dev/file-explorer without Composer
On this page you can find all versions of the php package anteris-dev/file-explorer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download anteris-dev/file-explorer
More information about anteris-dev/file-explorer
Files in anteris-dev/file-explorer
Package file-explorer
Short Description Bringing a little class to your filesystem operations
License MIT
Informations about the package file-explorer
Bringing a little class to your filesystem operations
This package seeks to make your filesystem operations easier by bringing in some easy-to-use verbal methods.
To Install
Run composer require anteris-dev/file-explorer
Requirements
- PHP ^7.4 for stricter type casting.
- Spatie Data-Transfer-Objects for file objects.
- Symfony Filesystem for their existing easy-to-use functions.
Getting Started
To get started with this package, create a new instance of the FileExplorer
class. If you pass a directory to the constructor, this will be your starting location, otherwise the current working directory is used.
Example:
Interacting with the File System
There are several methods that will help you to start interacting with the file system. These are listed below.
createDirectory( string $directory )
This method creates a new directory. If a relative path, this directory will be created relative to the current pointer. If absolute, it will be created at that location.
Example:
createAndEnterDirectory( string $directory )
Creates a new directory and sets the current context to that directory.
Example:
createFile( string $filename, $contents, bool $overwrite = false )
This method creates a new file. If a relative path, this file will be created relative to the current pointer. If absolute, it will be created at that location. Unless $overwrite is passed as true, the file will not be overwritten.
Example:
enterDirectory( string $directory )
Sets the current context of the class to this directory (think about entering a sub-folder within your file browser). If a relative path is passed, this is relative to the current directory context.
Example:
exists( string $pointer )
Returns true if the requested resource exists, otherwise false. This could be a file or directory. If the path passed is relative, this will be relative to the current directory context.
Example:
getCurrentDirectory()
Returns the current directory context of the class. This is where relative paths are resolved.
getDirectoryContents()
Returns a collection of files and directories in the current directory context.
Example:
goUp()
Sets the directory context to the parent folder.
Example:
isAbsolutePath(string $path)
Returns true if the path is absolute, otherwise false.
joinPaths(...$paths)
Joins multiple directory paths together. The end is suffixed with a forward slash, so this should not be used with filenames.
Example: