2017 © Pedro Peláez
 

library php-filereader

A simple filereader. PHP 7+

image

chillerlan/php-filereader

A simple filereader. PHP 7+

  • Tuesday, January 23, 2018
  • by codemasher
  • Repository
  • 1 Watchers
  • 2 Stars
  • 42 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 2 % Grown

The README.md

chillerlan/php-filereader

A simple file/directory reader for all (well, most... ok. some.) of your file-reading needs., (*1)

version ![license][license-badge] ![Travis][travis-badge] ![Coverage][coverage-badge] ![Scrunitizer][scrutinizer-badge] ![Packagist downloads][downloads-badge] ![PayPal donate][donate-badge], (*2)

Requirements

  • PHP 7.2+

Documentation

Installation

requires composer, (*3)

composer.json

(note: replace dev-master with a version boundary), (*4)

{
    "require": {
        "php": ">=7.2.0",
        "chillerlan/database": "dev-master"
    }
}

Manual installation

Download the desired version of the package from master or release and extract the contents to your project folder. After that: - run composer install to install the required dependencies and generate /vendor/autoload.php. - if you use a custom autoloader, point the namespace chillerlan\Filereader to the folder src of the package, (*5)

Profit!, (*6)

Usage

simple

You can just invoke one a FSDriverInterface and use it right away:, (*7)

use chillerlan\Filereader\Drivers\DiskDriver;

$filereader = new DiskDriver;
$filereader->isDir('/some/path');

advanced

$directory = new Directory($filereader, '/some/path');

/** @var \chillerlan\Filereader\File $file */
foreach($directory->read() as $file){
    echo $file->name;
    // ...
}

API

FSDriverInterface methods

method return
fileExists(string $path) bool
isFile(string $path) bool
fileContents(string $path) string
getRequire(string $path) mixed
deleteFile(string $path) bool
copyFile(string $source, string $destination, bool $overwrite = true) bool
isDir(string $path) bool
makeDir(string $path) bool
deleteDir(string $path) bool
rename(string $oldname, string $newname, bool $overwrite = true) bool

Directory public methods

method return
__construct(FSDriverInterface $driver, string $path) -
change(string $path) Directory
read() array of File objects
create(string $subdir = null) bool
delete(string $subdir = null) bool
rename(string $newname, bool $overwrite = true) Directory

File public methods

method return
__construct(FSDriverInterface $driver, Directory $directory, string $name) -
exists() bool
content() string
getRequire() mixed
copy(string $destination, bool $overwrite = true) bool
rename(string $newname, bool $overwrite = true) File
delete() bool

common magic properties of Directory and File

property type description
$path string the full path to the resource

additional magic properties of File

property type description
$name string the basename of the file
$directory Directory the Directory which contains the file

The Versions

23/01 2018

dev-master

9999999-dev https://github.com/chillerlan/php-filereader

A simple filereader. PHP 7+

  Sources   Download

MIT

The Requires

  • php >=7.0.3

 

The Development Requires

23/01 2018

1.0.1

1.0.1.0 https://github.com/chillerlan/php-filereader

A simple filereader. PHP 7+

  Sources   Download

MIT

The Requires

  • php >=7.0.3

 

The Development Requires

06/03 2017

1.0.0

1.0.0.0 https://github.com/codemasher/php-filereader

A simple filereader. PHP 7+

  Sources   Download

MIT

The Requires

  • php >=7.0.3

 

The Development Requires