Home  >  Q&A  >  body text

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 days ago666

reply all(3)I'll reply

  • 世界只因有你

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

    Because it is ok when you test it locally, it proves that the composer configuration is used correctly

    1. Check the running environment composer installation and permissions, and try writing a simple example

    2. Check the composer install execution results in the running environment

    3. What you should use is netease/nos-php-sdk. According to its configuration file, it uses the psr4 standard

    4. View./vendor/composer/autoload_psr4.php

    5. If the problem is not found above, it is recommended to modify ./vendor/autoload.php./vendor/composer/*文件打logdebugging to see where the problem is specifically

    reply
    0
  • 曾经蜡笔没有小新

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

    Classes are missing. Check whether there is a corresponding class under the corresponding namespace. If not, just introduce it

    reply
    0
  • 给我你的怀抱

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

    There are no dependencies to install the project on the server
    The first step is to install composer first,
    The second step is composer install to install the dependencies defined in composer.json

    reply
    0
  • Cancelreply