dqwd71332 2015-09-25 17:36
浏览 115

当使用PHP的exec()时,CasperJS无法正常工作PhantomJS执行正常

Alright so I've written a script for my job which uses CasperJS to grab a PDF and download it, then continue execution of the PHP script. I call this script using exec().

This works fine on my Windows 10 machine using XAMPP. However when I port it to my work laptop (a Macbook Pro running latest OSx) exec() will not work with casperJS. I can call phantomjs --version and casperjs --version from the terminal no problem, both were installed using node.js with the global flag. I've confirmed they are in usr/local/bin.

When I run exec("phantomjs --version", $output); It works fine and returns the phantomjs version.

When I run exec("casperjs --version", $output); It returns an empty array in output, rather than the version number.

I'm unsure why this is happening, and I've been googling and googling and no solutions. I found several topics here that had the same issues, and I implemented their solutions and it still won't work. My code for work is long and has a lot of information I can't share, but here is my test script I created to see if I could get around the issue.

I also want to specify that I am using XAMPP for Mac to run this, as I didn't want to take the time to setup a vagrant box, and setup the VPN stuff (that my script has to be run through) to run this script.

<?php
    putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs");
    putenv("DYLD_LIBRARY_PATH");
    putenv("PATH=/usr/local/bin");
    exec("casperjs --version", $output);

    print_r($output);
?>

I hate asking for help, but this script is going to take 2 more days to run, and because I have to be connected to the VPN, my primary computer I use for gaming, personal projects, etc is tied up and I'd LOVE to move this to my work laptop so that I can enjoy my personal computer this weekend.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题