decodelabs / atlas
Easy filesystem and io functions
Installs: 17 200
Dependents: 13
Suggesters: 2
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: ^8.1
- decodelabs/coercion: ^0.2
- decodelabs/deliverance: ^0.2.11
- decodelabs/enumerable: ^0.1.3
- decodelabs/exceptional: ^0.4
- decodelabs/glitch-support: ^0.4
- decodelabs/veneer: ^0.11.6
Requires (Dev)
This package is auto-updated.
Last update: 2024-11-04 21:15:45 UTC
README
Easy filesystem and IO functions for PHP
Atlas provides an easy and accessible interface to file system interaction. Read, write, copy and move files without breaking a sweat.
Get news and updates on the DecodeLabs blog.
Installation
Install via Composer:
composer require decodelabs/atlas
Usage
Importing
Atlas uses Veneer to provide a unified frontage under DecodeLabs\Atlas
.
You can access all the primary functionality via this static frontage without compromising testing and dependency injection.
Basic local filesystem functions
There are many standard filesystem functions represented by either File
or Dir
objects.
See Context.php, File/Local.php and Dir/Local.php for the full list.
use DecodeLabs\Atlas; Atlas::get('/path/to/dir_or_file') ->copyTo('/another/path/'); Atlas::createDir('some/dir/path', 0770); Atlas::file('my/file') ->renameTo('file.txt') ->setOwner('user'); Atlas::gzFile('my/file.gz', 'w') ->write('hello world') ->close();
Dir scanning
Scan the contents of a folder with optional filtering..
Replace "scan" for "list" to return an array rather than a Generator
:
use DecodeLabs\Atlas; foreach(Atlas::scan('my/dir') as $name => $fileOrDir) { // All files and dirs in my/dir } foreach(Atlas::scanDirs('my/dir') as $name => $dir) { // All dirs in my/dir } foreach(Atlas::listFilesRecursive('my/dir', function($name, $file) { // Return true if you want the file to be output return $name !== 'BadFile.php'; }) as $name => $file) { // All files in all dirs in my/dir }
See Fs.php or Dir/Local.php for all scanning options.
Channels & IO Broker
Looking for the IO Broker and Channel transfer interfaces?
This has been moved to its own project, Deliverance.
Mime types
Looking for the mime type detection stuff that used to be here?
This has been moved to its own project, Typify.
Licensing
Atlas is licensed under the MIT License. See LICENSE for the full license text.