Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1cce7f7

Browse files
Fixed an issue that when the project is imported via Composer, the PhantomJS execution file was not located due to referencing the Registry class property missing the vendor directory path.
1 parent 9329867 commit 1cce7f7

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

‎web/include/class/Registry.php‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ class Registry {
2020

2121
static public $sFilePath;
2222
static public $sDirPath;
23+
static public $sVendorDirPath;
2324
static public $sTempDirPath;
2425

25-
static public function setUp( $sFilePath ) {
26-
self::$sFilePath = $sFilePath;
27-
self::$sDirPath = dirname( self::$sFilePath );
28-
self::$sTempDirPath = sys_get_temp_dir() . '/' . self::SLUG;
26+
static public function setUp( $sFilePath, $sVendorDirPath='' ) {
27+
self::$sFilePath = $sFilePath;
28+
self::$sDirPath = dirname( self::$sFilePath );
29+
self::$sVendorDirPath = $sVendorDirPath
30+
? $sVendorDirPath
31+
: dirname( self::$sDirPath ) . '/vendor';
32+
self::$sTempDirPath = sys_get_temp_dir() . '/' . self::SLUG;
2933
// Includes
3034
/// Checking the file existence because when this is imported as a library via Composer, the vendor directory does not exist under this project directory.
3135
$_sAutoLoadPath = dirname( self::$sDirPath ) . '/vendor/autoload.php';

‎web/include/class/Scraper/ScraperHandler.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct( array $aRequest ) {
2323
}
2424
private function ___checkPhantomJSBinary() {
2525
$_sFileName = 'WIN' === Utility::getOS() ? 'phantomjs.exe' : 'phantomjs';
26-
$_sBinPath = dirname( Registry::$sDirPath ) . '/vendor/bin/' . $_sFileName;
26+
$_sBinPath = Registry::$sVendorDirPath. '/bin/' . $_sFileName;
2727
if ( ! file_exists( $_sBinPath ) ) {
2828
echo( 'PhantomJS bin not found: ' . $_sBinPath );
2929
Utility::listFolderFiles( dirname( Registry::$sDirPath ) );

‎web/index.php‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
ini_set('display_errors', 1);
66

77
require dirname( __FILE__ ) . '/include/class/Registry.php';
8-
\PHPSimpleWebScraper\Registry::setUp( __FILE__ );
8+
\PHPSimpleWebScraper\Registry::setUp(
9+
__FILE__,
10+
dirname( __DIR__ ) . '/vendor'
11+
);
912

1013
// HTTP Headers
1114
header( 'Access-Control-Allow-Origin: *' );

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /