Skip to content

Commit b6a0633

Browse files
committed
add readme
1 parent facff98 commit b6a0633

File tree

1 file changed

+90
-84
lines changed

1 file changed

+90
-84
lines changed

README.md

Lines changed: 90 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,132 @@
11
# laravel-filemanager
22

3-
### This package is functional, but is under active development.
3+
## Overview
44

5-
A file upload/editor intended for use with [Laravel 5](http://www.laravel.com/ "Title") and [CKEditor](http://ckeditor.com/).
5+
Fork from [tsawler/laravel-filemanager](http://packalyst.com/packages/package/tsawler/laravel-filemanager), add restriction that users can see only their own folders.
6+
The original functions support image and file upload, this package only modifies the image functions.
67

7-
## Rationale
8+
## Requirements
89

9-
There are other packages out there that offer much the same functionality, such as [KCFinder](http://kcfinder.sunhater.com/),
10-
but I found that integration with Laravel was a bit problematic, particularly when it comes to handling sessions
11-
and security.
10+
This package requires `"intervention/image": "2.*"`, in order to make thumbs, crop and resize images.
1211

13-
This package is written specifically for Laravel 5, and will integrate seamlessly.
12+
## Installation
1413

15-
## Requirements
14+
1. Run `composer require intervention/image`
1615

17-
1. This package only supports Laravel 5.x
18-
1. Requires `"intervention/image": "2.*"`
19-
1. Requires PHP 5.5 or later
16+
1. Edit `composer.json` file :
2017

21-
## Installation
18+
```json
19+
"require": {
20+
"unisharp/laravel-filemanager": "dev-master"
21+
},
22+
"repositories": [
23+
{
24+
"type": "git",
25+
"url": "git@github.com:UniSharp/laravel-filemanager.git"
26+
}
27+
],
28+
```
2229

23-
1. Installation is done through composer and packagist. From within your project root directory, execute the
24-
following command:
30+
1. Run `composer update`
2531

26-
`composer require tsawler/laravel-filemanager`
32+
1. Edit `config/app.php` :
2733

28-
1. Next run composer update to install the package from packagist:
34+
Add this in service providers
2935

30-
`composer update`
36+
- Laravel 5.0
3137

32-
1. Add the ServiceProvider to the providers array in config/app.php:
38+
```php
39+
'Tsawler\Laravelfilemanager\LaravelFilemanagerServiceProvider',
40+
'Intervention\Image\ImageServiceProvider',
41+
```
3342

34-
`'Tsawler\Laravelfilemanager\LaravelFilemanagerServiceProvider',`
43+
- Laravel 5.1
3544

36-
1. Publish the package's config file:
45+
```php
46+
Tsawler\Laravelfilemanager\LaravelFilemanagerServiceProvider::class,
47+
Intervention\Image\ImageServiceProvider::class,
48+
```
3749

38-
`php artisan vendor:publish --tag=lfm_config`
50+
And add this in class aliases
3951

40-
1. Publish the package's public folder assets:
52+
- Laravel 5.0
4153

42-
`php artisan vendor:publish --tag=lfm_public`
43-
44-
1. If you want to customize the look & feel, then publish the package's views:
54+
```php
55+
'Image' => 'Intervention\Image\Facades\Image',
56+
```
4557

46-
`php artisan vendor:publish --tag=lfm_views`
47-
48-
1. By default, the package will use its own routes. If you don't want to use those routes, change this entry in config/lfm.php to false:
58+
- Laravel 5.1
4959

5060
```php
51-
'use_package_routes' => true,
61+
'Image' => Intervention\Image\Facades\Image::class,
5262
```
53-
54-
You will, of course, have to set up your own routes.
55-
56-
1. If you don't want to use the default image/file directory or url, update the appropriate lines in config/lfm.php:
63+
64+
1. Edit `Kernel.php` :
65+
66+
Add this line in routeMiddleware
67+
68+
- Laravel 5.0
5769

5870
```php
59-
'images_dir' => 'public/vendor/laravel-filemanager/images/',
60-
'images_url' => '/vendor/laravel-filemanager/images/',
61-
'files_dir' => 'public/vendor/laravel-filemanager/files/',
62-
'files_url' => '/vendor/laravel-filemanager/files/',
71+
'myfolder' => '\Tsawler\Laravelfilemanager\middleware\OnlySeeMyFolder',
6372
```
64-
65-
1. Ensure that the files & images directories are writable by your web serber
6673

67-
1. In the view where you are using a CKEditor instance, use the file uploader by initializing the
68-
CKEditor instance as follows:
74+
- Laravel 5.1
75+
76+
```php
77+
'myfolder' => \Tsawler\Laravelfilemanager\middleware\OnlySeeMyFolder::class,
78+
```
79+
80+
1. Publish the package's config and assets :
81+
82+
`php artisan vendor:publish`
83+
84+
1. View initiation
6985

7086
```javascript
7187
<script>
7288
CKEDITOR.replace( 'editor', {
73-
filebrowserImageBrowseUrl: '/laravel-filemanager?type=Images',
74-
filebrowserBrowseUrl: '/laravel-filemanager?type=Files'
89+
filebrowserImageBrowseUrl: '/laravel-filemanager?type=Images'
7590
});
7691
</script>
7792
```
78-
79-
Here, "editor" is the id of the textarea you are transforming to a CKEditor instance. Note that if
80-
you are using a custom route you will have to change `/laravel-filemanager?type=Images` to correspond
81-
to whatever route you have chosen. Be sure to include the `?type=Images` parameter.
82-
83-
84-
## Security
85-
86-
It is important to note that if you use your own routes __you must protect your routes to Laravel-Filemanager in order to prevent
87-
unauthorized uploads to your server__. Fortunately, Laravel makes this very easy.
8893

89-
If, for example, you want to ensure that only logged in users have the ability to access the Laravel-Filemanager,
90-
simply wrap the routes in a group, perhaps like this:
94+
Or initiate using ckeditor jquery adapter
9195

92-
Route::group(array('before' => 'auth'), function ()
93-
{
94-
Route::get('/laravel-filemanager', 'Tsawler\Laravelfilemanager\controllers\LfmController@show');
95-
Route::post('/laravel-filemanager/upload', 'Tsawler\Laravelfilemanager\controllers\LfmController@upload');
96-
// list all lfm routes here...
97-
});
98-
99-
This approach ensures that only authenticated users have access to the Laravel-Filemanager. If you are
100-
using Middleware or some other approach to enforce security, modify as needed.
101-
102-
## License
96+
```javascript
97+
<script>
98+
$('textarea').ckeditor({
99+
filebrowserImageBrowseUrl: '/laravel-filemanager?type=Images'
100+
});
101+
</script>
102+
```
103103

104-
This package is released under the terms of the [MIT License](http://opensource.org/licenses/MIT).
104+
1. Ensure that the files & images directories are writable by your web server
105105

106-
The MIT License (MIT)
106+
## Customization
107+
108+
1. To use your own route, edit config/lfm.php :
107109

108-
Copyright (c) 2015 Trevor Sawler
110+
```php
111+
'use_package_routes' => false,
112+
```
113+
114+
1. To specify upload directory, edit config/lfm.php :
109115

110-
Permission is hereby granted, free of charge, to any person obtaining a copy
111-
of this software and associated documentation files (the "Software"), to deal
112-
in the Software without restriction, including without limitation the rights
113-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
114-
copies of the Software, and to permit persons to whom the Software is
115-
furnished to do so, subject to the following conditions:
116+
```php
117+
'images_dir' => 'public/vendor/laravel-filemanager/images/',
118+
'images_url' => '/vendor/laravel-filemanager/images/',
119+
```
116120

117-
The above copyright notice and this permission notice shall be included in
118-
all copies or substantial portions of the Software.
121+
1. If the route is changed, make sure `filebrowserImageBrowseUrl` is correspond to your route :
119122

120-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
121-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
122-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
123-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
124-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
125-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
126-
THE SOFTWARE.
123+
```javascript
124+
<script>
125+
CKEDITOR.replace( 'editor', {
126+
filebrowserImageBrowseUrl: '/laravel-filemanager?type=Images'
127+
});
128+
</script>
129+
```
130+
131+
And be sure to include the `?type=Images` parameter.
132+

0 commit comments

Comments
 (0)