જ્યારે ગ્રાબઝિટની પીએચપી લાઇબ્રેરી કોઈ લાઇબ્રેરી પ્રદાન કરવા પર ધ્યાન કેન્દ્રિત કરે છે જેનો ઉપયોગ કોઈપણ પીએચપી પ્રોજેક્ટમાં થઈ શકે છે. સિમ્ફની PHP, પ્રોજેક્ટ્સને એક અનન્ય રીતે એકસાથે મૂકવામાં આવ્યા છે, જેમાં થોડું વધારે કામની જરૂર છે.
સિમ્ફની એ મોટામાં મોટા પીએચપી ફ્રેમવર્કનો ઉપયોગ કરે છે જે હાલમાં તે પુસ્તકાલયો અને ઘટકોનો ફરીથી વાપરી શકાય તેવો સેટ પ્રદાન કરીને વેબ વિકાસને વેગ આપે છે. ટોરબેન લંડસગાર્ડના આભાર, જે હવે GrabzIt નો એક ભાગ છે ટીલેમિડિયા જેમણે સિમ્ફની માટે ગ્રાબઝિટનું બંડલ બનાવ્યું. આ ખુલ્લા સ્રોત સ softwareફ્ટવેરનો ઉપયોગ કરે છે એમઆઇટી લાઈસન્સ.
GrabzIt બંડલ મેળવવા માટે, તમારે પહેલા તેને કંપોઝર સાથે ઇન્સ્ટોલ કરવું આવશ્યક છે.
composer require tlamedia/grabzit-bundle
પછી તેને તમારી કર્નલમાં ઉમેરો.
public function registerBundles()
{
$bundles = array(
//...
new Tla\GrabzitBundle\TlaGrabzitBundle(),
//…
રૂપરેખાંકન
તમારું મેળવો API કી અને ગુપ્ત અને તેમને તમારી રૂપરેખા ફાઇલમાં ઉમેરવા.
# config.yml
tla_grabzit:
key: 'Sign in to view your Application Key'
secret: 'Sign in to view your Application Secret'
બંડલ અનેક સેવાઓ રજીસ્ટર કરે છે જેને જ્યારે યોગ્ય ગ્રાબઝિટ વર્ગ કહેવામાં આવે છે.
કuresપ્ચર્સ કેવી રીતે જનરેટ કરવી
સિમ્ફની ફ્રેમવર્કમાં થંબનેલ કેવી રીતે બનાવવું તેનું ઉદાહરણ.
namespace App\Service;
use Symfony\Component\DependencyInjection\ContainerInterface as Container;
class ThumbnailGenerator
{
private $container;
public function __construct(Container $container)
{
$this->router = $router;
$this->container = $container;
}
public function generateThumbnail($url)
{
$grabzItHandlerUrl = 'https://www.my-grabzit-thumbnail-site.com/api/thumbmail-ready';
$options = $this->container->get('tla_grabzit.imageoptions');
$options->setBrowserWidth(1366);
$options->setBrowserHeight(768);
$options->setFormat("png");
$options->setWidth(320);
$options->setHeight(240);
$options->setCustomId($domain);
$grabzIt = $this->container->get('tla_grabzit.client');
$grabzIt->URLToImage($url, $options);
$grabzIt->Save($grabzItHandlerUrl);
try {
$grabzIt->URLToImage($url, $options);
$grabzIt->Save($grabzItHandlerUrl);
$result = true;
} catch (\Throwable $t) {
$result = false;
}
return $result;
}
}
હેન્ડલર સાથે કેપ્ચર કેવી રીતે પ્રાપ્ત કરવું
સિમ્ફની ફ્રેમવર્કમાં હેન્ડલરનો ઉપયોગ કરીને ગ્રrabબિઝટમાંથી ક captપ્ચર્સ કેવી રીતે મેળવવું તેનું ઉદાહરણ. અલબત્ત, તમારે તમારી પોતાની જરૂરિયાતોને મેચ કરવા માટે આને બદલવાની જરૂર રહેશે.
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class ApiController extends Controller
{
public function thumbnailReadyAction(Request $request)
{
$id = urldecode($request->query->get('id'));
$customId = $request->query->get('customid');
$thumbnailFormat = $request->query->get('format');
if ($id && $customId && $thumbnailFormat) {
$grabzItApplicationKey = $this->container->getParameter('tla_grabzit.key');
if (0 === strpos($id, $grabzItApplicationKey)) {
$grabzIt = $this->container->get('tla_grabzit.client');
$result = $grabzIt->GetResult($id);
if ($result) {
$rootPath = $this->get('kernel')->getRootDir() . '/../';
$thumbnailsPath = $rootPath . 'var/thumbnails/';
$fileName = $customId. '.' .$thumbnailFormat;
file_put_contents($thumbnailsPath . $fileName, $result);
} else {
throw $this->createNotFoundException('GrabzIt did not return a file');
}
} else {
throw $this->createNotFoundException('Wrong key - Unauthorized access');
}
} else {
throw $this->createNotFoundException('Missing parameters');
}
return new Response(null, 200);
}
}
આ સહાય લેખનો વિસ્તાર વિસ્તૃત કરવામાં આવ્યો છે GitHub પર વિગતવાર આ બંડલ માટે સહાય કરો.