Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.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
Amazon MWS PHP客户端库在cron中执行时包含路径错误_Php_Amazon Web Services_Cron_Autoload_Amazon Mws - Fatal编程技术网

Amazon MWS PHP客户端库在cron中执行时包含路径错误

Amazon MWS PHP客户端库在cron中执行时包含路径错误,php,amazon-web-services,cron,autoload,amazon-mws,Php,Amazon Web Services,Cron,Autoload,Amazon Mws,因此,当我直接在浏览器中调用URL时,我有一个工作代码,它可以完美地工作。但是,当我在cron中设置相同的文件时,它会导致类not found错误。我认为set_include_path函数是导致错误的原因 我不小心修改了文件路径。下面是.config.inc.php的外观 set_include_path(get_include_path() . PATH_SEPARATOR . 'MarketplaceWebServiceProducts'); function __autol

因此,当我直接在浏览器中调用URL时,我有一个工作代码,它可以完美地工作。但是,当我在cron中设置相同的文件时,它会导致类not found错误。我认为set_include_path函数是导致错误的原因

我不小心修改了文件路径。下面是.config.inc.php的外观

 set_include_path(get_include_path() . PATH_SEPARATOR . 'MarketplaceWebServiceProducts');

     function __autoload($className){
        $filePath = str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
        $includePaths = explode(PATH_SEPARATOR, get_include_path());
        foreach($includePaths as $includePath){
            if(file_exists($includePath . DIRECTORY_SEPARATOR . $filePath)){
                require_once $filePath;
                return;
            }
        }
    }
我尝试将
dirname(\uuuu FILE\uuuu)
添加到$filepath变量前面以及set\u include\u path()函数中的实际文件夹MarketplaceWebServiceProducts之前。但是没有运气

这是我的cron命令

php -q /home4/username/example.com/_manager/a/_data_ru/getASINData.php
php客户端库位于/_data_ru/文件夹中

有人能指导我正确的方向吗?我需要做什么才能使它在cron中也能工作

非常感谢。

试试类似的东西

cd /home4/username/example.com/_manager/a/_data_ru && php -q getASINData.php
您使用的是相对路径,所以结果将取决于执行脚本的位置。您应该使用(如果需要父目录,则使用)使其更可预测:

set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/MarketplaceWebServiceProducts');