Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在管线Laravel 4中运行Artisan命令_Php_Laravel_Laravel 4_Phantomjs - Fatal编程技术网

Php 在管线Laravel 4中运行Artisan命令

Php 在管线Laravel 4中运行Artisan命令,php,laravel,laravel-4,phantomjs,Php,Laravel,Laravel 4,Phantomjs,尝试在路由上运行artisan命令时遇到问题 代码如下: Route::get('/create_preview', function() { Artisan::call('cartero:run-phantomjs', array('url' => 'http://stackoverflow.com/')); }); 我的命令接受url作为参数,我使用PhantomJS从给定的网站创建屏幕截图 在终端上工作得很好,但是我的浏览器调用路由时没有发生任何事情 有什么想法吗?试试这个

尝试在路由上运行artisan命令时遇到问题

代码如下:

Route::get('/create_preview', function() {
    Artisan::call('cartero:run-phantomjs', array('url' => 'http://stackoverflow.com/'));
});
我的命令接受url作为参数,我使用PhantomJS从给定的网站创建屏幕截图

在终端上工作得很好,但是我的浏览器调用路由时没有发生任何事情

有什么想法吗?

试试这个:

Artisan::call('cartero:run-phantomjs', array('--url' => 'http://stackoverflow.com/'));
拥有此命令:

Usage:
 firewall:blacklist [--force] ip

Arguments:
 ip                    The IP address to be added.

Options:
 --force               Remove IP before adding it to the list.
 --help (-h)           Display this help message.
 --quiet (-q)          Do not output any message.
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)        Display this application version.
 --ansi                Force ANSI output.
 --no-ansi             Disable ANSI output.
 --no-interaction (-n) Do not ask any interactive question.
 --env                 The environment the command should run under.
这对我有用:

Artisan::call('firewall:blacklist', ['ip' => '10.10.10.10']);

你说的是
,但我的浏览器调用路线时没有任何反应。
。没错,浏览器中不会显示任何内容,因为这是一个“仅限命令行”命令,终端打印的字符串、回音等不会在Artisan::call()中发送到浏览器,甚至不会出现错误。

这是服务器中的路径问题,以下是我的命令:

public function fire()
{
  $url = $this->argument('url');
  $filename = uniqid("sc");
  $path_phantomjs = base_path() . "/phantomjs/bin/phantomjs";
  $path_js = base_path() . "/screen.js";
  $path_dest = base_path() . "/public/uploads/previews/".$filename.".png";
  return exec($path_phantomjs . " " .$path_js . " " . $url . " " .$path_dest);
}

最初我没有使用helper base_path(),它在终端上运行良好,但在浏览器中不起作用。我添加了一条路径,现在可以工作了

--url,如果用于选项,则不用于参数。通过终端,我运行以下命令:
php artisan cartero:运行phantomjshttp://stackoverflow.com
而且效果很好……我的意思是,这在浏览器调用中不起作用,只在终端上。我说过,命令在浏览器中起作用,但如果它在您的命令中不起作用,您必须提供比命令行更多的信息,因为命令行不起作用,因为如果
url
是正确的参数,那么它应该对这两个参数都起作用。但是我们没有看到您的
cartero:runphantomjs
命令的内部结构,因此很难说.Done。我很抱歉,谢谢你!!!