PhantomJS 可在服务器上运行,但不能在 XAMPP 上运行
我在 XAMPP(已安装)MAC 上遇到 phantomJS 问题。上次,我使用的是 XAMPP-VM(适用于 Mac),但自从更新到 Monterey 后。它不起作用。我对这里的新环境有疑问。当尝试从 PHP 运行 PhantomJS 时。它显示
致命错误:未捕获 JonnyW\PhantomJs\Exception\NotWritableException: 由于目标不可写,文件无法写入系统: /var/folders/gd/6f7z77vj3ps0lvnyj88pxg_40000gn/T/b17136c6c91e8bb1fc7b 在 /Applications/XAMPP/xamppfiles/htdocs/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Cache/FileCache.php:65 堆栈跟踪:#0 /Applications/XAMPP/xamppfiles/htdocs/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Procedure/Procedure.php(188): JonnyW\PhantomJs\Cache\FileCache->保存('b17136c6c91e8bb...', '\n(函数(W,K)...') #1 /Applications/XAMPP/xamppfiles/htdocs/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Procedure/Procedure.php(98): JonnyW\PhantomJs\Procedure\Procedure->write('\n(function(W,K)...') #2 /Applications/XAMPP/xamppfiles/htdocs/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Procedure/ProcedureValidator.php(84): JonnyW\PhantomJs\Procedure\Procedure->run(Object(JonnyW\PhantomJs\Procedure\Input), 对象(JonnyW\PhantomJs\Procedure\Output)) #3 /Applications/XAMPP/xamppfiles/htdocs/vendor/jonnyw/php-pha 中 /Applications/XAMPP/xamppfiles/htdocs/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Cache/FileCache.php 第 65 行
这是
$client = Client::getInstance();
$client->getEngine()->setPath($_SERVER["DOCUMENT_ROOT"].'/bin/phantomjs');
$client->getEngine()->addOption('--cookies-file=' . $cookies);
$request = $client->getMessageFactory()->createRequest($url, 'GET');
$request->addSetting('userAgent', $userAgent);
$response = $client->getMessageFactory()->createResponse();
我所做的代码。
- 将权限更改为 777(对于 bin 及其内部文件)(用于测试目的)
- 在我的 Mac 上安装 phantomJS
I have problem with phantomJS at XAMPP(Installed) MAC. Last time, I am using XAMPP-VM (for Mac) but since update to Monterey. It does not work. I have problem with a new environment here. When trying to run PhantomJS from PHP. It shows
Fatal error: Uncaught JonnyW\PhantomJs\Exception\NotWritableException:
File could not be written to system as target is not writable:
/var/folders/gd/6f7z77vj3ps0lvnyj88pxg_40000gn/T/b17136c6c91e8bb1fc7b
in
/Applications/XAMPP/xamppfiles/htdocs/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Cache/FileCache.php:65
Stack trace: #0
/Applications/XAMPP/xamppfiles/htdocs/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Procedure/Procedure.php(188):
JonnyW\PhantomJs\Cache\FileCache->save('b17136c6c91e8bb...',
'\n(function(W,K)...') #1
/Applications/XAMPP/xamppfiles/htdocs/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Procedure/Procedure.php(98):
JonnyW\PhantomJs\Procedure\Procedure->write('\n(function(W,K)...') #2
/Applications/XAMPP/xamppfiles/htdocs/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Procedure/ProcedureValidator.php(84):
JonnyW\PhantomJs\Procedure\Procedure->run(Object(JonnyW\PhantomJs\Procedure\Input),
Object(JonnyW\PhantomJs\Procedure\Output)) #3
/Applications/XAMPP/xamppfiles/htdocs/vendor/jonnyw/php-pha in
/Applications/XAMPP/xamppfiles/htdocs/vendor/jonnyw/php-phantomjs/src/JonnyW/PhantomJs/Cache/FileCache.php
on line 65
Here is the code
$client = Client::getInstance();
$client->getEngine()->setPath($_SERVER["DOCUMENT_ROOT"].'/bin/phantomjs');
$client->getEngine()->addOption('--cookies-file=' . $cookies);
$request = $client->getMessageFactory()->createRequest($url, 'GET');
$request->addSetting('userAgent', $userAgent);
$response = $client->getMessageFactory()->createResponse();
Things I have done.
- Changing permission to 777 (for bin & the files inside it) (For Test Purpose)
- Installing phantomJS on my Mac
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论