Download the PHP package tarsana/io without Composer
On this page you can find all versions of the php package tarsana/io. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package io
Tarsana Filesystem Package
Simple classes to handle Filesystem operations.
Installation
Install it using composer
Handeling Files and Directories
The Filesystem
class was designed to be used easily and support call chaining which makes the code more readable.
Checking Paths
Maybe you need to check if a specific path is a file
or a directory
or you just want to know it exists, no matter it's a file or directory
What if you need to check multiple paths at once ?
But what if you want to know the type of a path without having to do multiple checks ?
You can use wildcard pattern as argument to this function and the result will be:
-
'file'
: if a single file corresponds to the pattern. -
'dir'
: if a single directory corresponds to the pattern. -
'collection'
: if multiple files and/or directories correspond to the pattern. 'nothing'
: if nothing corresponds to the pattern.
Finding Files and Directories
Now what if you want to get all files and directories corresponding to a pattern ?
You can also manipulate the collection
Handling Files
Well, to handle a file, you should get it first
Notice that this will throw an exception if the file is not found. If you want to create it when missing; specify true
in the second argument
You can also get or create multiple files at once
Now that you have the file, you can play with it
Notice that all setters return the same instance to enable call chaining.
Handling Directories
Just like the file, you can get a directory like that
Having a directory, you can play with it
Notice that all setters return the same instance to enable call chaining.
Reading & Writing to Resources
Writer
Tarsana\Filesystem\Resource\Writer
gives the possibility to write content to any resource.
Reader
Tarsana\Filesystem\Resources\Reader
gives the possibility to read content from any resource. Constructors are the same as Writer
but the default resource is STDIN
.
Buffer
Tarsana\Filesystem\Resource\Buffer
is a Reader and Writer at the same time. If no resource is given, it uses php://memory
to store content.