intervention/image-symfony

Symfony Integration of Intervention Image

1.0.1 2024-04-04 18:17 UTC

This package is auto-updated.

Last update: 2024-04-04 18:18:20 UTC


README

Symfony Integration for Intervention Image

Latest Version Monthly Downloads

This package provides an integration to setup Intervention Image easily to your Symfony framework application. Although the use of this integration library is not absolutely necessary, it offers a convenient way of central configuration in the Symfony framework.

Requirements

  • Symfony >= 7

Installation

In your existing Symfony application you can install this package using Composer.

composer require intervention/image-symfony

After successful installation, you can activate the bundle in the file config/bundes.php of your application by inserting the following line into the array.

return [
    // ...
    Intervention\Image\Symfony\InterventionImageBundle::class => ['all' => true],
];

Configuration

By default, the bundle is configured to use the GD library with Intervention Image. However, the package also offers other drivers. This can be easily configured by creating a file config/packages/intervention_image.yaml and setting the driver class as follows.

intervention_image:
  driver: Intervention\Image\Drivers\Imagick\Driver

You can choose between the two supplied drivers Intervention\Image\Drivers\Gd\Driver and Intervention\Image\Drivers\Imagick\Driver for example.

Getting Started

The integration is now complete and it is possible to access the ImageManager via dependency injection.

namespace App\Controller;

use Intervention\Image\ImageManager;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class ExampleController extends AbstractController
{
    #[Route('/')]
    public function example(ImageManager $manager): Response
    {
        $image = $manager->read('images/example.jpg');
    }
}

Read the official documentation of Intervention Image for more information.

Authors

This library is developed and maintained by Oliver Vogel

Thanks to the community of contributors who have helped to improve this project.

License

Intervention Image Symfony is licensed under the MIT License.