PHPackages                             expectedbehavior/php-docraptor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. expectedbehavior/php-docraptor

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

expectedbehavior/php-docraptor
==============================

Official PHP wrapper for the DocRaptor API.

1.3.0(10y ago)843.3k1[1 issues](https://github.com/expectedbehavior/php-docraptor/issues)BSD-3-ClausePHPPHP &gt;=5.4.0CI failing

Since Apr 6Pushed 4y ago8 watchersCompare

[ Source](https://github.com/expectedbehavior/php-docraptor)[ Packagist](https://packagist.org/packages/expectedbehavior/php-docraptor)[ Docs](https://github.com/expectedbehavior/php-docraptor)[ RSS](/packages/expectedbehavior-php-docraptor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (7)Used By (0)

[![Build Status](https://camo.githubusercontent.com/c43cbcb0afeaffde39ed1eb707b63bb43e7862cc82f577bc6841b208c3b9eb39/68747470733a2f2f7472617669732d63692e6f72672f65787065637465646265686176696f722f7068702d646f63726170746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/expectedbehavior/php-docraptor) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/6d92d389c480a767c0332cc6caab994c84e8c26757501234b7df4eed5a1624ef/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f65787065637465646265686176696f722f7068702d646f63726170746f722f6261646765732f7175616c6974792d73636f72652e706e67)](https://scrutinizer-ci.com/g/expectedbehavior/php-docraptor/)

\#PHP-DocRaptor

PHP-DocRaptor is a simple API wrapper for [DocRaptor.com](https://docraptor.com/). You will need a DocRaptor [account](https://docraptor.com/plans) before you can use this library, as it requires a valid API key.

\##Dependencies This wrapper requires PHP 5.4 or newer. PHP 5.4 support will be dropped when it reaches EOL. We strongly advise to migrate your projects to PHP 5.6. Other than that, only the PHP curl extension is needed.

At the moment, this library still works with PHP 5.3, but we don't guarantee that for any future releases.

\##Installation

This library is PSR-4 autoloading compliant and you can install it via composer. Just require it in your `composer.json`.

```
"require": {
    "expectedbehavior/php-docraptor": "1.3.0"
}
```

Then run `composer update` resp. `composer install`.

\##Usage

```
$docRaptor = new DocRaptor\ApiWrapper("YOUR_API_KEY_HERE"); // Or omit the API key and pass it in via setter
$docRaptor->setDocumentContent('Hello!')->setDocumentType('pdf')->setTest(true)->setName('output.pdf');
$file = $docRaptor->fetchDocument();
```

`fetchDocument` returns document contents by default. You can optionally provide a file path to the `fetchDocument` method, and the wrapper will attempt to write the returned value to that file path.

\###Options

\####Setting Prince Specific Options The API wrapper has the ability to set `prince_options` that is noted in the [API documentation](https://docraptor.com/documentation#pdf_options), where available keys are listed.

Example of setting prince version and [PDF profile](https://en.wikipedia.org/wiki/PDF/A#PDF.2FA-1):

```
$docRaptor = new DocRaptor\ApiWrapper("YOUR_API_KEY_HERE");
$docRaptor
    ->setDocumentContent('Hello!')
    ->setDocumentType('pdf')
    ->setTest(true)
    ->setName('output.pdf')
    ->setDocumentPrinceOptions(array(
        'version' => '10',
        'profile' => 'PDF/A-1b',
    ));
$file = $docRaptor->fetchDocument();
```

\####Asynchronous By default, PHP-DocRaptor submits requests sychronously. However, if you are trying to process large documents, you can make an asynchronous doc request. You can choose to do this by passing an argument to the `setAsync` method (`true` for asynchronous, `false` for synchronous request):

```
$docRaptor->setAsync(true);
```

Synchronous requests will return the file contents where as asynchronous requests will return a json response. Examples of the response can be found in the [API documentation](https://docraptor.com/documentation#api_async)

\####Async Callback URL If `setAsync(true)` is called and you want DocRaptor to do a POST request to your system when an asynchronous job has finished you can set the callback url via `setCallbackUrl`:

```
$docRaptor->setCallbackUrl('http://example.com/callback');
```

Details on the POST request can be found in the [API documentation](https://docraptor.com/documentation#api_callback_url)

\####HTTPS or HTTP By default, PHP-DocRaptor submits requests over https. You can choose to submit via http by passing an argument to the `setSecure` method (`true` for https, `false` for http):

```
$docRaptor->setSecure(false);
```

NB! It IS not secure, you're basically broadcasting your api key over the network.

### Privacy

[](#privacy)

By default this library will report usage statistics - the api wrapper version and PHP version - to the DocRaptor service by way of a user agent string. You can disable this by providing a config object to the `ApiWrapper` constructor or the `HttpClient` constructor.

```
$config     = new DocRaptor\Config(false);
$httpClient = new DocRaptor\HttpClient($config);
$docRaptor  = new DocRaptor\ApiWrapper("YOUR_API_KEY_HERE", $httpClient, $config);
// or
$config    = new DocRaptor\Config(false);
$docRaptor = new DocRaptor\ApiWrapper("YOUR_API_KEY_HERE", null, $config); // will use HttpClient by default
```

### Alternate HTTP Implementation

[](#alternate-http-implementation)

Since we're injecting a `HttpTransferInterface` interface into the `ApiWrapper` you can either inject the provided `HttpClient` or inject your own implementation of the interface.

```
$httpClient = new DocRaptor\HttpClient();
$docRaptor  = new DocRaptor\ApiWrapper("YOUR_API_KEY_HERE", $httpClient);
```

The provided `HttpClient` is a very simple domain specific curl wrapper that extracts all curl functions from the `ApiWrapper` which makes it possible to inject a mock client for testing.

Contributing
------------

[](#contributing)

If you find a bug, please make a [new GitHub issue](https://github.com/expectedbehavior/php-docraptor/issues/new). If you know how to solve it, make a branch and once you're done make a [new pull request](https://github.com/expectedbehavior/php-docraptor/compare).

When submitting a PR, you will need to [install composer](https://getcomposer.org/doc/00-intro.md) to run the tests. Once you have it installed, in the project root, run `composer install`. To run the tests from the project root, run `vendor/bin/phpunit`. They should all pass! Also we have travis and scrutinizer integration, so you can check those in your PR for things that could be better or don't work.

Releasing
---------

[](#releasing)

With the new version number:

- Update [`CHANGELOG.markdown`](https://github.com/expectedbehavior/php-docraptor/blob/master/CHANGELOG.markdown)
- Update [`composer.json`](https://github.com/expectedbehavior/php-docraptor/blob/master/composer.json)
- Update install directions in [`README.markdown`](https://github.com/expectedbehavior/php-docraptor/blob/master/README.markdown#installation)
- Update [`Config.php`](https://github.com/expectedbehavior/php-docraptor/blob/master/src/Config.php)
- `git tag `
- `git push origin master --tags`

After pushing your new tagged version, make sure the new version shows up on [Packagist](https://packagist.org/packages/expectedbehavior/php-docraptor).

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 70.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~28 days

Recently: every ~21 days

Total

6

Last Release

3918d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0025b2d8b4c78eccdc0151f59be62747dde7519e75d0ea37a38819bf04ee89e2?d=identicon)[janxious](/maintainers/janxious)

---

Top Contributors

[![janxious](https://avatars.githubusercontent.com/u/50124?v=4)](https://github.com/janxious "janxious (75 commits)")[![rsands2801](https://avatars.githubusercontent.com/u/5500424?v=4)](https://github.com/rsands2801 "rsands2801 (16 commits)")[![krewenki](https://avatars.githubusercontent.com/u/19960?v=4)](https://github.com/krewenki "krewenki (13 commits)")[![illbzo1](https://avatars.githubusercontent.com/u/27860?v=4)](https://github.com/illbzo1 "illbzo1 (1 commits)")[![ladamson](https://avatars.githubusercontent.com/u/4666833?v=4)](https://github.com/ladamson "ladamson (1 commits)")[![rbrotherton](https://avatars.githubusercontent.com/u/1571250?v=4)](https://github.com/rbrotherton "rbrotherton (1 commits)")

---

Tags

phppdfxlsxlsxxhtmldocraptorprincexml

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/expectedbehavior-php-docraptor/health.svg)

```
[![Health](https://phpackages.com/badges/expectedbehavior-php-docraptor/health.svg)](https://phpackages.com/packages/expectedbehavior-php-docraptor)
```

###  Alternatives

[mk-j/php_xlsxwriter

PHP Library to write XLSX files

1.9k8.1M27](/packages/mk-j-php-xlsxwriter)[avadim/fast-excel-writer

Lightweight and very fast XLSX Excel Spreadsheet Writer in PHP

2951.2M7](/packages/avadim-fast-excel-writer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
