2017 © Pedro Peláez
 

library laravel-phantomjs

Use phantom-js in laravel

image

josh/laravel-phantomjs

Use phantom-js in laravel

  • Monday, July 2, 2018
  • by iamalirezaj
  • Repository
  • 2 Watchers
  • 12 Stars
  • 1,134 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 1 Open issues
  • 8 Versions
  • 29 % Grown

The README.md

Build Status Latest Stable Version Total Downloads Latest Unstable Version Discord License, (*1)

Laravel PhantomJs Client

Using php-phantomjs client in laravel, (*2)

php-phantomjs Documentation, (*3)

Requirement

Install

Via Composer, (*4)

$ composer require josh/laravel-phantomjs

Config

Add the following provider to providers part of config/app.php, (*5)

Josh\Component\PhantomJs\PhantomJsServiceProvider::class

and the following Facade to the aliases part, (*6)

'PhantomJs' => Josh\Component\PhantomJs\Facade\PhantomJs::class

and then you can run vendor:publish command for generating phantomjs config file bash $ php artisan vendor:publish --provider="Josh\Component\PhantomJs\PhantomJsServiceProvider", (*7)

Now you can config your phantomjs client in config/phantomjs.php file

Basic Usage

The following illustrates how to make a basic GET request and output the page content:, (*8)

On Load Finished

// Tells the client to wait for all resources before rendering

$request = \PhantomJs::get('https://www.google.com/');

\PhantomJs::isLazy()->send($request);
// you can use Facade or app make function to use phantomjs
// ex: app('phantomjs') or \PhantomJs

$request = \PhantomJs::get('https://www.google.com/');

$response = \PhantomJs::send($request);

if($response->getStatus() === 200) {

    // Dump the requested page content
    echo $response->getContent();
}

Saving a screen capture to local disk:, (*9)


$request = \PhantomJs::createImage('https://www.google.com/', 'GET'); $request->setOutputFile(public_path('file.jpg')); $request->setViewportSize(800, 600); $request->setCaptureDimensions(800, 600, 0, 0); $response = \PhantomJs::send($request); if($response->getStatus() === 200) { // Dump the requested page content echo $response->getContent(); }

Outputting a page as PDF:, (*10)

$request = \PhantomJs::createPdf('https://www.google.com/', 'GET');
$request->setOutputFile(public_path('document.pdf'));
$request->setFormat('A4');
$request->setOrientation('landscape');
$request->setMargin('1cm');

$response = \PhantomJs::send($request);

if($response->getStatus() === 200) {

    // Dump the requested page content
    echo $response->getContent();
}

License

The MIT License (MIT), (*11)

The Versions

02/07 2018

dev-develop

dev-develop

Use phantom-js in laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alireza Josheghani

laravel phantomjs phantomjs-php phantom-js

02/07 2018

1.0.2

1.0.2.0

Use phantom-js in laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alireza Josheghani

laravel phantomjs phantomjs-php phantom-js

12/02 2018

1.0.1

1.0.1.0

Use phantom-js in laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alireza Josheghani

laravel phantomjs phantomjs-php phantom-js

12/02 2018

1.0.0

1.0.0.0

Use phantom-js in laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alireza Josheghani

laravel phantomjs phantomjs-php phantom-js

24/12 2017

0.0.4

0.0.4.0

  Sources   Download

MIT

The Requires

 

by Alireza Josheghani

24/12 2017

0.0.3

0.0.3.0

  Sources   Download

MIT

The Requires

 

by Alireza Josheghani

23/12 2017

0.0.2

0.0.2.0

  Sources   Download

MIT

The Requires

 

by Alireza Josheghani

08/05 2017

0.0.1

0.0.1.0

  Sources   Download

MIT

The Requires

 

by Alireza Josheghani