Heim  >  Fragen und Antworten  >  Hauptteil

php - class not found?

正在尝试网易蜂巢的对象存储,按照文档上的做法,现在vps上的文件夹结构是这样的:

index.php是这样的:

<?php
require_once __DIR__ . '/vendor/autoload.php';

use NOS\NosClient;
use NOS\Core\NosException;

$accessKeyId = "xxxxxxxxxxxxxx";
$accessKeySecret = "xxxxxxxxxxxxxxxxxxxx";
$endPoint = "nos-eastchina1.126.net";
$bucket = "testtest1";

try{
        $nosClient = new NosClient($accessKeyId,$accessKeySecret,$endPoint);
        $nosClient->createBucket($bucket);
} catch(NosException $e){
        print $e->getMessage();
}

运行的时候提示:Fatal error: Class 'NOS\NosClient' not found in /data/wwwroot/default/index.php on line 14

但是把这些放在我本地测试的时候是没问题的,是我漏掉了什么?
求解,真心感谢。

更新:
是NOS这个包自己的问题,按照他们客服所说用了新的包之后问题解决。

PHP中文网PHP中文网2713 Tage vor665

Antworte allen(3)Ich werde antworten

  • 世界只因有你

    世界只因有你2017-05-16 13:14:17

    因为你在本地测试的时候ok,证明composer配置使用正确

    1. 检查运行环境composer安装和权限,写一个简单的例子试试

    2. 检测一下运行环境中 composer install 执行结果

    3. 你应该使用的是netease/nos-php-sdk,根据它的配置文件来看,使用的是psr4标准

    4. 查看./vendor/composer/autoload_psr4.php

    5. 如果以上没有找出问题,建议修改./vendor/autoload.php./vendor/composer/*文件打log调试,看具体是那里出了问题

    Antwort
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 13:14:17

    缺少类了。看对应的命名空间下是否有对应的类。没有的话,就引入就可以了

    Antwort
    0
  • 给我你的怀抱

    给我你的怀抱2017-05-16 13:14:17

    服务器上没有安装项目的依赖
    第一步先安装composer,
    第二步composer install 安装composer.json里定义的依赖

    Antwort
    0
  • StornierenAntwort