PHP PhantomJS无法在Web服务器上运行

时间:2016-02-12 16:05:57

标签: php phantomjs php-phantomjs

有下一个问题:在MAMP上安装了php phantomjs。全部使用此处的说明:enter link description here

一切都很好......然后我将我的所有网站文件复制到我的网站托管网站文件夹,没有任何效果。做了一个var_dump的响应,看到了:

  

对象(JonnyW \ PhantomJs \ Http \ Response)#156(8){[“headers”] => NULL [“status”] => NULL [“content”] => NULL [“contentType”] => NULL [“url”] => NULL [“redirectURL”] => NULL [“time”] => NULL [“console”] => NULL}

为什么它不起作用,为什么所有都是NULL? 我的代码是:

int rowNum = 10;
int colNum = 10;
int gridHeight = 10;
int gridWidth = 10;

public void start(Stage primaryStage) {
    GridPane grid = new GridPane();

    //grid.getColumnConstraints().add(new ColumnConstraints(gridWidth));
    //grid.getRowConstraints().add(new RowConstraints(gridHeight));

    Random rand = new Random();
    Color[] colors = {Color.BLACK, Color.BLUE, Color.GREEN, Color.RED};

    int n = rand.nextInt(4)+1;
    for(int row = 0; row < rowNum; row++){
           for(int col = 0; col < colNum; col++){
               Rectangle rec = new Rectangle();
               rec.setWidth(2);
               rec.setHeight(2);
               rec.setFill(colors[n]);
               GridPane.setRowIndex(rec, row);
               GridPane.setColumnIndex(rec, col);
               grid.getChildren().addAll(rec);
           }
    }

    Scene scene = new Scene(grid, 350, 250);

    primaryStage.setTitle("Grid");
    primaryStage.setScene(scene);
    primaryStage.show();
}

2 个答案:

答案 0 :(得分:1)

最有可能的事情是,如果它是共享主机,它们可能不会允许您执行任意可执行文件...即~/bin/phantomjs

中的可执行文件

要执行非标准的用户安装内容,您需要一台VPS或专用服务器。

答案 1 :(得分:0)

问题是关于作曲家下载的可执行文件,所以关注issue #86我把它放在我的代码上:

$client->getEngine()->setPath('/usr/bin/phantomjs');

所以现在我正在使用默认二进制文件,效果很好。

相关问题