{"id":18781541,"url":"https://github.com/devture/browserless","last_synced_at":"2025-04-13T12:05:41.898Z","repository":{"id":56967120,"uuid":"471049249","full_name":"devture/browserless","owner":"devture","description":"Library for communicating with the https://www.browserless.io/ API (generating PDFs, etc.)","archived":false,"fork":false,"pushed_at":"2024-01-10T18:13:25.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-18T02:54:58.488Z","etag":null,"topics":["browserless","chrome","pdf","pdf-generation","puppeteer"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devture.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-17T16:02:53.000Z","updated_at":"2024-08-01T17:33:26.000Z","dependencies_parsed_at":"2023-02-12T15:02:17.911Z","dependency_job_id":null,"html_url":"https://github.com/devture/browserless","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devture%2Fbrowserless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devture%2Fbrowserless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devture%2Fbrowserless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devture%2Fbrowserless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devture","download_url":"https://codeload.github.com/devture/browserless/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223585766,"owners_count":17169364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["browserless","chrome","pdf","pdf-generation","puppeteer"],"created_at":"2024-11-07T20:32:18.262Z","updated_at":"2025-04-13T12:05:41.892Z","avatar_url":"https://github.com/devture.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Browserless\n\nThis is a library for interacting with the [Browserless.io](https://www.browserless.io) APIs.\n\nFor the time being, this library only supports these APIs:\n\n- [/pdf](https://docs.browserless.io/docs/pdf.html) - for generating PDFs from a URL or inline HTML (like [wkhtmltopdf](https://wkhtmltopdf.org/), but better -- more up-to-date browser engine, etc.)\n\n\n## Prerequisites\n\nYou either need to use your own self-hosted Browserless instance (see how to do it with [Docker](https://docs.browserless.io/docker/quickstart)) or their hosted offering (see [Pricing](https://www.browserless.io/pricing/)).\n\nYou could use the following `compose.yml` setup:\n\n```yaml\nversion: '2.1'\n\nservices:\n  browserless:\n    image: ghcr.io/browserless/chromium:v2.23.0\n    restart: unless-stopped\n    # Matches the owner (`blessuser:blessuser`) of `/usr/src/app`\n    user: 999:999\n    environment:\n      CONCURRENT: 10\n      TOKEN: SOME_TOKEN_HERE\n    # Not exposing the port is recommended, if PHP is running in a container alongisde this one\n    ports:\n      - \"127.0.0.1:3000:3000\"\n    tmpfs:\n      - /tmp\n```\n\n\n## Usage\n\n### Creating a Browserless API client\n\n```php\n$browserlessApiUrl = 'http://localhost:3000'; // Or 'http://browserless:3000', etc.\n$browserlessToken = 'SOME_TOKEN_HERE';\n$browserlessTimeoutSeconds = 15;\n\n$client = new \\Devture\\Component\\Browserless\\Client(\n\tnew \\GuzzleHttp\\Client(),\n\t$browserlessApiUrl,\n\t$browserlessToken,\n\t$browserlessTimeoutSeconds,\n);\n```\n\n\n### Generating a PDF from a URL\n\n```php\n$url = 'https://devture.com';\n\n$pdfCreationRequest = new \\Devture\\Component\\Browserless\\Model\\PdfCreationRequest();\n$pdfCreationRequest-\u003esetUrl($url);\n$pdfCreationRequest-\u003esetOptions([\n\t'printBackground' =\u003e true,\n\t'format' =\u003e 'A4',\n\t'landscape' =\u003e true,\n]);\n\n$pdfBytes = $client-\u003ecreatePdfFromRequest($pdfCreationRequest);\n```\n\n\n### Generating a PDF from inline HTML\n\n```php\n$html = '\u003chtml\u003e\u003cbody\u003eSome \u003cstrong\u003eHTML\u003c/strong\u003e here\u003c/body\u003e\u003c/html\u003e';\n\n$pdfCreationRequest = new \\Devture\\Component\\Browserless\\Model\\PdfCreationRequest();\n$pdfCreationRequest-\u003esetHtml($html);\n$pdfCreationRequest-\u003esetOptions([\n\t'printBackground' =\u003e true,\n\t'format' =\u003e 'A4',\n\t'margin' =\u003e [\n\t\t'top' =\u003e '20mm',\n\t\t'bottom' =\u003e '10mm',\n\t\t'left' =\u003e '10mm',\n\t\t'right' =\u003e '10mm',\n\t],\n]);\n\n$pdfBytes = $client-\u003ecreatePdfFromRequest($pdfCreationRequest);\n```\n\n## Alternatives\n\n- [gosuperscript/browserless-php](https://packagist.org/packages/gosuperscript/browserless-php)\n\n- the [SynergiTech/chrome-pdf-php](https://github.com/SynergiTech/chrome-pdf-php) library can also render PDFs via Browserless\n\n- [wkhtmltopdf](https://wkhtmltopdf.org/) invoked via [knplabs/knp-snappy](https://github.com/KnpLabs/snappy)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevture%2Fbrowserless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevture%2Fbrowserless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevture%2Fbrowserless/lists"}