1. Go to this page and download the library: Download imponeer/smarty-image 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/ */
imponeer / smarty-image example snippets
$smarty = new \Smarty\Smarty();
// For $psrCacheAdapter value use PSR-6 cache adapter, for example Symfony\Component\Cache\Adapter\ArrayAdapter
$smarty->addExtension(
new \Imponeer\Smarty\Extensions\Image\SmartyImageExtension($psrCacheAdapter)
);
// In your controller or service
public function __construct(
private Smarty $smarty,
private SmartyImageExtension $imageExtension
) {
$this->smarty->addExtension($this->imageExtension);
}
use Psr\Cache\CacheItemPoolInterface;
use Imponeer\Smarty\Extensions\Image\SmartyImageExtension;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
return [
CacheItemPoolInterface::class => \DI\create(FilesystemAdapter::class),
SmartyImageExtension::class => \DI\create()
->constructor(\DI\get(CacheItemPoolInterface::class)),
Smarty::class => \DI\factory(function (SmartyImageExtension $imageExtension) {
$smarty = new Smarty();
$smarty->addExtension($imageExtension);
return $smarty;
})
];
use League\Container\Container;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Imponeer\Smarty\Extensions\Image\SmartyImageExtension;
$container = new Container();
$container->add(CacheItemPoolInterface::class, ArrayAdapter::class);
$container->add(SmartyImageExtension::class)
->addArgument(CacheItemPoolInterface::class);
$container->add(Smarty::class)
->addMethodCall('addExtension', [SmartyImageExtension::class]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.