ਜਦੋਂ ਕਿ GrabzIt ਦੀ PHP ਲਾਇਬ੍ਰੇਰੀ ਇੱਕ ਲਾਇਬ੍ਰੇਰੀ ਪ੍ਰਦਾਨ ਕਰਨ 'ਤੇ ਕੇਂਦ੍ਰਤ ਕਰਦੀ ਹੈ ਜੋ ਕਿਸੇ ਵੀ PHP ਪ੍ਰੋਜੈਕਟ ਵਿੱਚ ਵਰਤੀ ਜਾ ਸਕਦੀ ਹੈ. ਸਿਮਫੋਨੀ PHP ਪ੍ਰੋਜੈਕਟਾਂ ਨੂੰ ਇੱਕ ਵਿਲੱਖਣ ਤਰੀਕੇ ਨਾਲ ਇਕੱਠਾ ਕੀਤਾ ਜਾਂਦਾ ਹੈ ਜਿਸ ਲਈ ਥੋੜਾ ਹੋਰ ਕੰਮ ਕਰਨ ਦੀ ਲੋੜ ਹੁੰਦੀ ਹੈ।
ਸਿਮਫਨੀ ਵਰਤਮਾਨ ਸਮੇਂ ਵਿੱਚ ਵਰਤੇ ਜਾਣ ਵਾਲੇ ਸਭ ਤੋਂ ਵੱਡੇ PHP ਫਰੇਮਵਰਕ ਵਿੱਚੋਂ ਇੱਕ ਹੈ ਇਹ ਲਾਇਬ੍ਰੇਰੀਆਂ ਅਤੇ ਭਾਗਾਂ ਦਾ ਇੱਕ ਮੁੜ ਵਰਤੋਂ ਯੋਗ ਸੈੱਟ ਪ੍ਰਦਾਨ ਕਰਕੇ ਵੈੱਬ ਵਿਕਾਸ ਨੂੰ ਤੇਜ਼ ਕਰਦਾ ਹੈ। ਕਿਸ GrabzIt ਹੁਣ ਇੱਕ ਹਿੱਸਾ ਹੈ, Torben Lundsgaard ਦੇ ਲਈ ਧੰਨਵਾਦ TLAMedia ਜਿਸਨੇ Symfony ਲਈ GrabzIt ਦਾ ਇੱਕ ਬੰਡਲ ਬਣਾਇਆ। ਇਹ ਓਪਨ ਸੋਰਸ ਸੌਫਟਵੇਅਰ ਦੀ ਵਰਤੋਂ ਕਰਦਾ ਹੈ MIT ਲਾਇਸੰਸ.
GrabzIt ਬੰਡਲ ਨੂੰ ਪ੍ਰਾਪਤ ਕਰਨ ਲਈ ਤੁਹਾਨੂੰ ਪਹਿਲਾਂ ਇਸਨੂੰ ਕੰਪੋਜ਼ਰ ਨਾਲ ਸਥਾਪਿਤ ਕਰਨਾ ਚਾਹੀਦਾ ਹੈ।
composer require tlamedia/grabzit-bundle
ਫਿਰ ਇਸਨੂੰ ਆਪਣੇ ਕਰਨਲ ਵਿੱਚ ਸ਼ਾਮਲ ਕਰੋ।
public function registerBundles() { $bundles = array( //... new Tla\GrabzitBundle\TlaGrabzitBundle(), //…
ਆਪਣਾ ਲਵੋ ਏਪੀਆਈ ਕੁੰਜੀ ਅਤੇ ਗੁਪਤ ਅਤੇ ਉਹਨਾਂ ਨੂੰ ਆਪਣੀ ਸੰਰਚਨਾ ਫਾਈਲ ਵਿੱਚ ਇਸ ਤਰ੍ਹਾਂ ਸ਼ਾਮਲ ਕਰੋ.
# config.yml tla_grabzit: key: 'Sign in to view your Application Key' secret: 'Sign in to view your Application Secret'
ਬੰਡਲ ਕਈ ਸੇਵਾਵਾਂ ਨੂੰ ਰਜਿਸਟਰ ਕਰਦਾ ਹੈ ਜਿਨ੍ਹਾਂ ਨੂੰ ਬੁਲਾਉਣ 'ਤੇ ਢੁਕਵੀਂ GrabzIt ਕਲਾਸ ਵਾਪਸ ਆਉਂਦੀ ਹੈ।
ਸੇਵਾ ਪਛਾਣਕਰਤਾ | GrabzIt ਕਲਾਸ |
---|---|
tla_grabzit.client | GrabzItClient |
tla_grabzit.imageoptions | GrabzItImageOptions |
tla_grabzit.pdfoptions | GrabzItPDFOptions |
tla_grabzit.docxoptions | GrabzItDOCXOptions |
tla_grabzit.animationoptions | GrabzItAnimationOptions |
tla_grabzit.tableoptions | GrabzItTableOptions |
ਸਿਮਫਨੀ ਫਰੇਮਵਰਕ ਵਿੱਚ ਇੱਕ ਥੰਬਨੇਲ ਕਿਵੇਂ ਤਿਆਰ ਕਰਨਾ ਹੈ ਦੀ ਇੱਕ ਉਦਾਹਰਨ।
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; } }
ਸਿਮਫਨੀ ਫਰੇਮਵਰਕ ਵਿੱਚ ਇੱਕ ਹੈਂਡਲਰ ਦੀ ਵਰਤੋਂ ਕਰਕੇ GrabzIt ਤੋਂ ਕੈਪਚਰ ਕਿਵੇਂ ਪ੍ਰਾਪਤ ਕੀਤੇ ਜਾਣ ਦੀ ਇੱਕ ਉਦਾਹਰਨ। ਬੇਸ਼ੱਕ ਤੁਹਾਨੂੰ ਆਪਣੀਆਂ ਲੋੜਾਂ ਨਾਲ ਮੇਲ ਕਰਨ ਲਈ ਇਸ ਨੂੰ ਬਦਲਣ ਦੀ ਲੋੜ ਪਵੇਗੀ।
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 'ਤੇ ਵੇਰਵੇ ਵਾਲੇ ਇਸ ਬੰਡਲ ਲਈ ਮਦਦ.