PHP code example of bencagri / photon-bundle
1. Go to this page and download the library: Download bencagri/photon-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bencagri / photon-bundle example snippets
composer
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
....
//Photon Bundle
new \Bencagri\PhotonBundle\PhotonBundle(),
];
use Photon\Wrapper\Effect\Filter;
use Photon\Wrapper\Effect\Width;
use Photon\Wrapper\Effects;
...
public function indexAction(Request $request)
{
//get the service
$generator = $this->get('bencagri.photon.service');
//register the effects that you want to use
$effects = new Effects(
new Width(700),
new Filter('emboss')
);
$imageUrl = 'https://images.com/my.jpg';
//generate the picture
$generator->setImageUrl($imageUrl);
$generator->setEffects($effects);
$generator->generate();
}