Thursday 18 February 2016

Intervention Library Integration With Laravel

Laravel Intervention
Intervention is an image library. It is a very good library for processing images and gives a very short solution for processing images in your application. It comes with several built in functions to help you with image processing.

In this tutorial i will tell you how to integrate this amazing library with Laravel 5.2. I searched a lot but i was unable to get this knowledge at one point


so i thought to write it down.

Requirements 


In order to install this library you must have one of these two libraries  

  • GD Library (>=2.0) … or …
  • Imagick PHP extension (>=6.5.7)
Note:  I am assuming here that you are working in latest environment and have .
  • PHP >= 5.4
  • Fileinfo Extension
That's all we need to install this amazing library so far.

Getting Started  

Now to get started you first need to install this library in your project folder but to do this you must have to run this command in your project folder as in my case i am assuming that my XAMPP is in D: so the path will be

d:\xampp\htdocs\'project_name'
After coming in this folder in cmd run the following command. 

$ php composer.phar require intervention/image

 Now your composer.jsaon has been updated automatically and you are able to require the just created vendor/autoload.php file to PSR-4 autoload the librayr.The library is now installed in your current project but its not over yet. 

Intervention image has optional support for Laravel and comes  with a Service provider and Facad  intergration. The vendor/autoload.php  is included by Laravel , so you dont have to require or auto manually. Just do as i say.

After Installation go to laravel config/app.php and in there in the $providers array add this line 

Intervention\Image\ImageServiceProvider::Class

 Add the facade of thus package to $aliases array in the same file

'Image' => Intervention\Image\Facaes\Image::class

Now the image class will be autoloaded by laravel 





No comments:

Post a Comment