在symfony中放置phantomjs脚本的位置


Where to put phantomjs script in symfony?

我想使用以下行从symfony服务运行bash命令phantomjs myAwesomeScript.js "www.example.com"

$response = exec("phantomjs $scriptPath $arguments");

我可以把我的脚本myAwesomeScript.js放在哪里?例如,我可以把这个放在app/exec/trollingUrl.js中吗?还是我应该把这个放在另一个地方?

如何在symfony中正确获取该文件的路径?

使用npm install -globabl phantomjs 安装phantomJS

如果您在unix系统下运行,PhantomJS将安装在/usr/local中。这意味着il将可以在您的命令行上从的任何地方访问

以全局方式安装后,您只需执行<?php exec("phantomjs $scriptPath $arguments");?>在您的任何php脚本中,无需担心phantomjs安装路径

有关全局安装的更多信息,请点击此处:http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation