-
Notifications
You must be signed in to change notification settings - Fork 0
/
WkHtmlToPdfBinary.php
40 lines (32 loc) · 1 KB
/
WkHtmlToPdfBinary.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace corpoflow\WkHtmlToPdfBinary;
/**
* Class WkHtmlToPdfBinary
*
* @package corpoflow\WkHtmlToPdfBinary
*/
class WkHtmlToPdfBinary {
/**
* @param bool $binary
*
* @return string
*/
public static function path($binary = false) {
# No specific binary passed, so go detect
if ($binary === false) {
# Check if we're on x32 or x64
$architecture = PHP_INT_SIZE == 4 ? '32' : '64';
switch (strtolower(PHP_OS)) {
case 'linux': # Linux
$binary = 'wkhtmltopdf-linux-' . $architecture;
break;
case 'windows': # Windows
$binary = 'wkhtmltopdf-windows-' . $architecture . '.exe';
break;
default: # Always fallback to linux x64
$binary = 'wkhtmltopdf-linux-amd64';
}
}
return __DIR__ . DIRECTORY_SEPARATOR . 'binaries' . DIRECTORY_SEPARATOR . $binary;
}
}