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