nordsoftware / lumen-image-manager
Image manager module for the Lumen framework.
Installs: 630
Dependents: 0
Suggesters: 0
Security: 0
Stars: 23
Watchers: 15
Forks: 2
Open Issues: 1
Requires
- php: >=5.5.9
- cloudinary/cloudinary_php: ~1.1
- nordsoftware/lumen-file-manager: ~1.0
Requires (Dev)
- laravel/lumen-framework: v5.1.*
Suggests
- league/fractal: Install to serialize files using ImageTransformer
README
Image manager for the Lumen PHP framework.
Please note that this module is still under active development.
Requirements
- PHP 5.5.9 or newer
- Composer
- FileManager
Usage
Installation
Run the following command to install the package through Composer:
composer require nordsoftware/lumen-image-manager
Bootstrapping
Please note that we only support Cloudinary for now.
Add the following lines to bootstrap/app.php
:
$app->register('Nord\Lumen\Cloudinary\CloudinaryServiceProvider');
$app->register('Nord\Lumen\ImageManager\ImageManagerServiceProvider');
You can now use the ImageManager
facade or inject the Nord\Lumen\ImageManager\Contracts\ImageManager
where needed.
Example
Below is an example of how to use this module to save an image from the request and return a JSON response with the saved image's ID and URLs.
public function uploadImage(Request $request, FileManager $fileManager, ImageManager $imageManager) { // Save the image directly to Cloudinary $file = $fileManager->saveFile($request->file('upload'), ['disk' => 'cloudinary']); return Response::json([ 'id' => $file->getId(), 'url' => $imageManager->getImageUrl($file, ['transformation' => 'small']) ]); }
Contributing
Please read the guidelines.
License
See LICENSE.