2016-12-12 00:07:23 +00:00
|
|
|
```yaml
|
|
|
|
module: filedriver
|
|
|
|
version: 1.0
|
|
|
|
requires: null
|
|
|
|
```
|
|
|
|
|
|
|
|
Overview
|
|
|
|
----
|
|
|
|
|
|
|
|
##### 1. Introduction
|
2016-12-12 00:08:37 +00:00
|
|
|
The `filedriver` package allows you to **create**, **read** and **write** files easily and with optimization (cf. SplFileObject).
|
2016-12-12 00:07:23 +00:00
|
|
|
|
|
|
|
To make it easier and generic, all methods are static.
|
|
|
|
|
|
|
|
Setup
|
|
|
|
----
|
|
|
|
> 1. Include the autoloader
|
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once '../autoloader.php';
|
|
|
|
|
|
|
|
...
|
|
|
|
```
|
|
|
|
|
|
|
|
> 2. Load the `FileDriver` class
|
|
|
|
|
|
|
|
```php
|
|
|
|
<?php
|
|
|
|
|
|
|
|
...
|
|
|
|
|
|
|
|
use \filedriver\core\FileDriver;
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
Usage
|
|
|
|
----
|
|
|
|
|
|
|
|
### FileDriver
|
|
|
|
|
|
|
|
##### `create` - creates or empty a file
|
|
|
|
|
|
|
|
> ```php
|
|
|
|
<?php
|
|
|
|
create(String $filename) : bool
|
|
|
|
```
|
|
|
|
|
|
|
|
##### `read` - reads a whole file
|
|
|
|
|
|
|
|
> ```php
|
|
|
|
<?php
|
|
|
|
read(String $filename) : String
|
|
|
|
```
|
|
|
|
|
|
|
|
##### `readline` - reads a specific line
|
|
|
|
|
|
|
|
> ```php
|
|
|
|
<?php
|
|
|
|
readline(String $filename, Integer $line) : String
|
|
|
|
```
|
|
|
|
|
|
|
|
##### `write` - writes content (erase if not empty)
|
|
|
|
|
|
|
|
> ```php
|
|
|
|
<?php
|
|
|
|
write(String $filename, String $content) : bool
|
|
|
|
```
|
|
|
|
|
|
|
|
##### `append` - append content at the end of a file
|
|
|
|
|
|
|
|
> ```php
|
|
|
|
<?php
|
|
|
|
append(String $filename, String $content) : bool
|
|
|
|
```
|