Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion config/browsershot.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@

'npmBinary' => env('NPM_BINARY_PATH', ''),

/*
|--------------------------------------------------------------------------
| Node Modules PATH
|--------------------------------------------------------------------------
|
| The location of node_modules.
|
*/

'nodeModules' => env('NODE_MODULES_PATH', base_path('node_modules')),

/*
|--------------------------------------------------------------------------
| Proxy Server
Expand Down Expand Up @@ -69,5 +80,5 @@
|
*/

'additionalOptions' => []
'additionalOptions' => [],
];
33 changes: 17 additions & 16 deletions src/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Spatie\Browsershot\Browsershot;
use Spatie\Image\Manipulations;
use VerumConsilium\Browsershot\Traits\Responsable;
use VerumConsilium\Browsershot\Traits\ContentLoadable;
use VerumConsilium\Browsershot\Traits\Responsable;
use VerumConsilium\Browsershot\Traits\Storable;

/**
Expand All @@ -17,25 +17,26 @@ abstract class Wrapper
use Responsable, ContentLoadable, Storable;

/**
* Browsershot base class to generate PDFs
* Browsershot base class to generate PDFs.
*
* @var \Spatie\Browsershot\Browsershot
*/
protected $browsershot;

/**
* Directory where the temporary pdf will be stored
*
* @var string
*/
* Directory where the temporary pdf will be stored.
*
* @var string
*/
protected $tempFile;

public function __construct(string $url = 'http://github.com/verumconsilium/laravel-browsershot')
{
$browsershot = new Browsershot($url);
$browsershot->setNodeBinary(config('browsershot.nodeBinary'))
->setNpmBinary(config('browsershot.npmBinary'))
->setProxyServer(config('browsershot.proxyServer'));
->setNodeModulePath(config('browsershot.nodeModules'))
->setNpmBinary(config('browsershot.npmBinary'))
->setProxyServer(config('browsershot.proxyServer'));

// @codeCoverageIgnoreStart
if (!empty(config('browsershot.chromePath'))) {
Expand All @@ -57,21 +58,21 @@ public function __construct(string $url = 'http://github.com/verumconsilium/lara
}

/**
* Extension file of the generated output
* Extension file of the generated output.
*
* @return string
*/
abstract protected function getFileExtension(): string;

/**
* Mime Type of the generated output
* Mime Type of the generated output.
*
* @return string
*/
abstract protected function getMimeType(): string;

/**
* Access underlying browsershot instance
* Access underlying browsershot instance.
*
* @return Browsershot
*/
Expand All @@ -81,7 +82,7 @@ protected function browsershot(): Browsershot
}

/**
* Gets the temp file path
* Gets the temp file path.
*
* @return string
*/
Expand All @@ -93,7 +94,7 @@ public function getTempFilePath(): string
}

/**
* Reads the output from the generated temp file
* Reads the output from the generated temp file.
*
* @return string|null
*/
Expand All @@ -105,7 +106,7 @@ protected function getTempFileContents(): ?string
}

/**
* Generates temp file
* Generates temp file.
*
* @return Wrapper
*/
Expand All @@ -121,7 +122,7 @@ protected function generateTempFile(): Wrapper
}

/**
* Delegates the call of methods to underlying Browsershot
* Delegates the call of methods to underlying Browsershot.
*
* @param string $name
* @param array $arguments
Expand All @@ -138,7 +139,7 @@ public function __call($name, $arguments): Wrapper
}

/**
* Unlink temp files if any
* Unlink temp files if any.
*
* @codeCoverageIgnore
* @return array
Expand Down