README.markdown 2.25 KB
Newer Older
1
BNRepo - Data Repositories (Local, FTP, SFTP, S3...)
Thorsten Buss's avatar
Thorsten Buss committed
2
3
4
5
=========

BNRepo is a PHP5 library based on [Gaufrette](https://github.com/KnpLabs/Gaufrette), that provides different Repositories for filesystem abstraction.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
The RepositoryManager is lazy - no actions or objects before the first use


Getting Started
----------

### 1. Create Config File (Local Dirs, FTP, SFTP, S3)
```yaml
# repositories.yml
bnrepo-test:
 - type: local
 - dir: /tmp
```

### 2. Import Configuration for your Repositories
```php
  RepositoryManager::importRepositoriesFromYamlFile('repositories.yml');
```

### 3. Get the Repository from the RepositoryManager

```php
  $repo = RepositoryManager::getRepository('bnrepo-test');
```

### 4. Read/Write/Download/Upload Data/Files

```php
  $repo->write('test.txt', 'Hello World');
  echo $repo->read('test.txt') // prints Hello World
```

Documentation
-------

### Configuration

Setup your ConfigFile repositories.yml:
```yml
bnrepo-test-local:
  type: local
  dir: /tmp/bnrepo-test
  create: true

bnrepo-test-s3:
  type: s3
  aws_key: AWS_KEY
  aws_secret: AWS_SECRET
  bucket: bnrepo-test
  dir: bnrepo-test
  create: true
  use_old_version: true
  options:
    default_acl: public-read #DEFAULT is only BucketOwner can read, so everyone with the link can read

bnrepo-test-ftp:
  type: ftp
  host: HOST
  username: USERNAME
  password: PASSWORD
  dir: /bnrepo-test
  passive: false

bnrepo-test-sftp:
  type: sftp
  host: HOST
  port: PORT
  dir: /bnrepo-test
  username: USERNAME
  password: PASSWORD
```

### Load the Configuration

```php
  RepositoryManager::importRepositoriesFromYamlFile('repositories.yml');
```

### Use the Repositories


```php
  $repo = RepositoryManager::getRepository('bnrepo-test');
```

**Every Repository is an \Gaufrette\Filesystem, so check out there [docs](https://github.com/KnpLabs/Gaufrette) too.**

Running the Tests
-----------------

The tests use PHPUnit.

### Setup the vendor libraries

As some filesystem adapters use vendor libraries, you should install the vendors:

    $ cd BNRepo
    $ php composer.phar install

Implement the configurations for the repositories you want to test and remove the *-DISABLED* postfix.
Without Configuration the hole AdapterTest would skipped.

### Launch the Test Suite

    $ phpunit

Is it green?
Thorsten Buss's avatar
Thorsten Buss committed
113