2012-10-05 32 views
1

我正在尝试使用gearman使用GearmanClient类从gearman-php-extensions创建任务。我能够在下面的程序运行使用命令prompt-Yii无法找到GearmanClient

//php client.php works fine 
<?php 
$client= new GearmanClient(); 
$client->addServer(); 
$task = $client->do("send", "hi"); 
?> 

但我wan't运行在一些yii controller这个代码。看起来好像yii是无法找到类的路径达到GearmanClient,但为什么?

另外我正在写程序eclipse。由于php命令和eclipse都使用相同的php库,所以我的yii控制器应该正常工作。相反,我的浏览器提供了错误的喜欢 -

PHP warning 

include(GearmanClient.php): failed to open stream: No such file or directory 
#plus some warnings and the yii stack trace. 
+0

该文件位于何处?你怎么包括它?上面代码中的 –

+0

是'protected/controllers/ReportsController.php'的一部分。希望你知道'yii'层次结构。当我在client.php中放入5行代码片段时,它可以在'terminal'中使用'php <程序名称>'。但它不能在浏览器中运行。 – Hussain

+2

不,我的意思是,'GearmanClient.php'文件在哪里?你怎么包括它?你可能会指定错误的路径,这将是PHP为你提供这样的错误的原因。 –

回答

2

这是因为发生的事情,不更新正在处理的PHP文件的过程与最新的php.ini配置。所以你只需要重新启动这个过程。

因此:

  1. 如果PHP处理程序运行作为Web服务器模块,那么你就需要重新启动Web服务器。

  2. 如果你有php作为cgi进程运行,那么你需要重启那个进程。