Skip to content

TurboLabIt/php-chrome-headless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-chrome-headless

A simple wrapper to run chrome-php/chrome with caching and logging.

๐Ÿ’ฟ 1. Install Chrome

sudo apt install curl -y && curl -s https://raw.githubusercontent.com/TurboLabIt/webstackup/master/script/chrome/install.sh?$(date +%s) | sudo bash

See: webstackup/script/chrome/

๐Ÿ’ฟ 2. (optional) Install PDF Support

If you want to use Chrome to generate PDFs, you also need this:

sudo apt install curl -y && curl -s https://raw.githubusercontent.com/TurboLabIt/webstackup/master/script/print/install-pdf.sh?$(date +%s) | sudo bash

See: webstackup/script/print/

๐Ÿ“ฆ 3. Install the package with composer

composer config repositories.turbolabit/php-chrome-headless git https://github.com/TurboLabIt/php-chrome-headless.git
composer require turbolabit/php-chrome-headless:dev-main

4. โš™๏ธ Symfony custom configuration (optional)

# config/packages/chromeheadless.yaml
turbo_lab_it_chrome_headless:
  $arrConfig:
    pdf:
      browser:
        marginTop: 1.5
        marginBottom: 1.5

See: services.yaml

๐Ÿ•ธ 4. Scrape a page

<?php
 
?>

See: ChromeHeadlessTest

๐Ÿ•ธ 5. HTML to PDF

<?php
 
?>

See: ChromeHeadlessTest

๐Ÿงช Test it

git clone git@github.com:TurboLabIt/php-chrome-headless.git
cd php-chrome-headless
clear && bash script/test_runner.sh

About

A simple wrapper to run Chrome Headless via PHP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published