PhantomJS 可在服务器上运行,但不能在 XAMPP 上运行

发布于 2025-01-15 19:41:32 字数 1759 浏览 4 评论 0原文

我在 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();

我所做的代码。

  1. 将权限更改为 777(对于 bin 及其内部文件)(用于测试目的)
  2. 在我的 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.

  1. Changing permission to 777 (for bin & the files inside it) (For Test Purpose)
  2. Installing phantomJS on my Mac

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文