issetbv/alfredo-laravel

此包的最新版本(dev-master)没有可用的许可证信息。

Laravel 的 Alfredo 包装器

dev-master 2013-10-25 09:12 UTC

This package is not auto-updated.

Last update: 2024-09-24 01:02:07 UTC


README

此包仅是针对 Laravel 编写的 Alfredo 包装器。它将简化来自 Alfredo 客户端的许多任务。

目录

文档

安装

使用方法

许可证

# Documentation The full documentation on Alfredo can be [found here](http://online-pdfconverter.nl/guide) # Requirements * PHP 5.3 # Installation 1. Add requirement to composer.json
```json "issetbv/alfredo-laravel": "dev-master" ``` 
  1. Update dependencies

    composer update
  2. Publish configuration file

    php artisan config:publish issetbv/alfredo-laravel
  3. Add Service Provider to the providers array in app/config/app.php

    'IssetBv\AlfredoLaravel\AlfredoServiceProvider',
  4. Add Facade to the facades array in app/config/app.php

    'Alfredo' => 'IssetBv\AlfredoLaravel\Facade',
  5. Add API keys to the configuration file in app/config/packages/issetbv/alfredo-laravel/config.php

# Usage **Create payload** ```php $payload = Alfredo::makePayload(); ``` **Add source to payload**

Available: addHtml, addPdf, addUrl

$payload = Alfredo::makePayload(); $payload->addUrl('http://isset.nl');
**Create payload with converter type** ```php $payload = Alfredo::makePayloadWithConverter('htmltopdfjava'); ``` **Create payload with callback url for queues** ```php $payload = Alfredo::makePayloadWithCallback('http://example.com/callback_url'); ``` **Create payload with sources**

Available: html, pdf, url

$payload = Alfredo::makePayloadWithSources(array( array('url', 'http://isset.nl'), array('html', '<html><thead></thead><tbody>Create payload with sources!</tbody></html>') ));
**Convert a payload** ```php $payload = Alfredo::makePayload(); $payload->addHtml('Converting a payload!'); $pdf = Alfredo::convert($payload); ``` **Stream a payload or converted payload**

Stream a payload:

$payload = Alfredo::makePayload(); $payload->addHtml('<html><thead></thead><tbody>Streaming a payload!</tbody></html>'); $response = Alfredo::stream($payload); // returns a Response object

Stream a converted payload:

$payload = Alfredo::makePayload(); $payload->addHtml('<html><thead></thead><tbody>Streaming a converted payload!</tbody></html>'); $pdf = Alfredo::convert($payload); $response = Alfredo::stream($pdf); // returns a Response object
**Queue a payload**

When using the queue, its necessary to set the callback url.

$payload = Alfredo::makePayloadWithCallback('http://example.com/callback_url'); $payload->addHtml('<html><thead></thead><tbody>Queueing a payload!</tbody></html>'); $response = Alfredo::queue($payload); // returns a JSON response
{ "response":"Queued", "identifier":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }
**Check if a queued payload has been converted** ```php if (Alfredo::checkQueuedPayload('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')) { // returns a boolean // Payload has been converted and is ready to be downloaded } ``` **Get converted payload from queue** ```php $pdf = Alfredo::getQueuedPayload('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); ``` **Stream converted payload from queue** ```php $pdf = Alfredo::getQueuedPayload('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); $response = Alfredo::stream($pdf); ```

License

MIT