Skip to content

Commit e7804d6

Browse files
committed
Upd README.md
1 parent 7265abc commit e7804d6

File tree

1 file changed

+62
-20
lines changed

1 file changed

+62
-20
lines changed

README.md

+62-20
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,16 @@
1818

1919
## Installation
2020

21+
1. Installing using Composer
2122
```
2223
composer require rkit/filemanager-yii2
2324
```
25+
26+
2. Run migrations
27+
```
28+
php yii migrate --migrationPath=@vendor/rkit/filemanager-yii2/src/migrations/ --interactive=0
29+
```
30+
2431
## Configuration
2532

2633
Add the following in your config, in section `components`
@@ -44,7 +51,9 @@ Add the following in your config, in section `components`
4451
]
4552
```
4653

47-
## Basic usage
54+
## Usage
55+
56+
### Basic usage
4857

4958
1. **Controller**
5059

@@ -96,6 +105,9 @@ Add the following in your config, in section `components`
96105
// save file id in this table
97106
// 'saveFileId' => true,
98107

108+
// protected a file
109+
// 'protected' => true,
110+
99111
// @see http://www.yiiframework.com/doc-2.0/guide-tutorial-core-validators.html
100112
'rules' => [
101113
'imageSize' => ['minWidth' => 300, 'minHeight' => 300],
@@ -137,15 +149,9 @@ Add the following in your config, in section `components`
137149

138150
3. **View**
139151

140-
Any widget for ajax upload.
141-
Use `$model->getFileRulesDescription($attribute)` for get a description of rules
142-
```
143-
Min. size of image: 300x300px
144-
File types: JPG, JPEG, PNG
145-
Max. file size: 1.049 MB
146-
```
152+
Any widget for ajax upload
147153

148-
## Thumbnails
154+
### Thumbnails
149155

150156
- Apply a preset and return public path
151157

@@ -165,7 +171,7 @@ Add the following in your config, in section `components`
165171
$model->thumb('preview', '200x200', null, true);
166172
```
167173

168-
## Gallery
174+
### Gallery
169175

170176
1. **Controller**
171177

@@ -199,7 +205,7 @@ Add the following in your config, in section `components`
199205
</li>
200206
```
201207

202-
## Save after upload
208+
### Save after upload
203209

204210
For example this could be a need for wysiwyg editor,
205211
when you need to immediately save the file after upload and assign the owner.
@@ -221,16 +227,52 @@ public function actions()
221227
}
222228
```
223229

224-
## Manually create a file
230+
### Manually create a file from path
231+
232+
```php
233+
object Yii::$app->fileManager->create('/path/to/file', $ownerId, $model->getFileOwnerType($attribute), true);
234+
```
235+
236+
### Manually create a file from URL
225237

226-
- From path
238+
```php
239+
object Yii::$app->fileManager->create('http://…/path/to/file', $ownerId, $model->getFileOwnerType($attribute), true);
240+
```
227241

228-
```php
229-
Yii::$app->fileManager->create('/path/to/file', $ownerId, $model->getFileOwnerType($attribute), true)
230-
```
242+
### Manually create a **protected** file from path
231243

232-
- From URL
244+
```php
245+
object Yii::$app->fileManager->create('/path/to/file', $ownerId, $model->getFileOwnerType($attribute), true, true);
246+
```
233247

234-
```php
235-
Yii::$app->fileManager->create('http://…/path/to/file', $ownerId, $model->getFileOwnerType($attribute), true)
236-
```
248+
### Get files
249+
250+
```php
251+
array $model->getFiles($attribute);
252+
```
253+
254+
### Сheck whether a file is protected
255+
256+
```php
257+
bool $model->isProtected($attribute);
258+
```
259+
260+
### Get a description of rules
261+
262+
```php
263+
string $model->getFileRulesDescription($attribute)
264+
```
265+
266+
Output
267+
268+
```
269+
Min. size of image: 300x300px
270+
File types: JPG, JPEG, PNG
271+
Max. file size: 1.049 MB
272+
```
273+
274+
### Get real path to file
275+
276+
```php
277+
string $model->getFileRealPath($attribute);
278+
```

0 commit comments

Comments
 (0)