【问题标题】:Fix Error in Amazon PHP SDK修复 Amazon PHP SDK 中的错误
【发布时间】:2017-08-01 23:10:03
【问题描述】:

您好,我正在使用 Amazon PHP SDK 上传到 s3。我在前端使用fineuploader jQuery 插件。最近我的托管PHP版本升级到PHP5.4.34并没有上传系统坏了,当我查看日志时看到这个错误。

<br />
<b>Fatal error</b>:  Uncaught exception 'LogicException' with message 'Illegal value passed (no array or string given)' in /home/on2dvd/public_html/fineuploader/aws/aws-autoloader.php:1270
Stack trace:
#0 /home/on2dvd/public_html/fineuploader/aws/aws-autoloader.php(1270): spl_autoload_register(NULL, true)
#1 /home/on2dvd/public_html/fineuploader/s3/s3handler.php(27): require('/home/on2dvd/pu...')
#2 {main}
  thrown in <b>/home/on2dvd/public_html/fineuploader/aws/aws-autoloader.php</b> on line <b>1270</b><br />

我搜索了很多,但找不到任何解决方案。错误出现在 aws-autoloader.php 第 1270 行,在这一行代码如下。 $mapping 是一个包含键和类名的数组。它在 PHP 5.3 中运行良好,但升级后不再运行。

spl_autoload_register(function ($class) use ($mapping) {
    if (isset($mapping[$class])) {
        require $mapping[$class];
    }
}, true);

【问题讨论】:

    标签: php amazon-web-services amazon-s3


    【解决方案1】:

    大家好,我在这里找到了解决问题的方法。

    https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md

    我从上面的 url 中使用了这个函数,它解决了我的问题。

    function autoload($className)
    {
        $className = ltrim($className, '\\');
        $fileName  = '';
        $namespace = '';
        if ($lastNsPos = strrpos($className, '\\')) {
            $namespace = substr($className, 0, $lastNsPos);
            $className = substr($className, $lastNsPos + 1);
            $fileName  = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
        }
        $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
    
        require $fileName;
    }
    spl_autoload_register('autoload');
    

    【讨论】:

      【解决方案2】:

      检查您是否安装了 eAccelerator:How to monitor eaccelerator

      如果是这种情况,只需在项目的.htaccess中添加这两行即可:

      php_flag eaccelerator.enable 0
      php_flag eaccelerator.optimizer 0
      

      【讨论】:

        猜你喜欢
        • 2013-09-10
        • 2021-04-08
        • 1970-01-01
        • 1970-01-01
        • 2012-06-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-08-07
        相关资源
        最近更新 更多