PHP类未正确加载具有空构造函数

时间:2015-01-15 23:11:14

标签: php

所以我有一个课程:

require_once('../../application/libraries/video.php');
$video = new Video();
$url = $video->load_thumb($this->project_id, $this->hash_name);

问题是该类似乎没有加载。所以我检查了它的存在:

if (class_exists('Video'))
{
    $array = get_class_methods('Video');
    die(var_dump($array));
}

返回给我:

array (size=3)
  0 => string '__construct' (length=11)
  1 => string 'load_url' (length=8)
  2 => string 'load_thumb' (length=10)

所以我删除了所有死掉的垃圾并将原始代码放回上面。无论怎样我都无法调用load_thumb。如果我死了$ video,则不会返回任何内容。没有错误没有警告,没有。

为什么课程没有加载?

编辑:video.php的内容

使用TwentyTwenty \ QualBoard \ IoC; 使用Intervention \ Image \ ImageManagerStatic作为ImageManager;

class Video
{
    var $CI;
    var $files;

    function __construct()
    {
        $this->files = IoC::resolve('files');
    }

    function load_url ($projectId, $storageName, $width = null, $height = null)
    {
        $file = $this->files->projectVideo($projectId, $storageName, $width, $height);

        if ($file->exists())
        {
            return $file->getLink();
        }

        return null;
    }

    function load_thumb($projectId, $storageName, $width = 400, $height = 400)
    {
        $file = $this->files->projectVideoScreenshot($projectId, $storageName, $width, $height);

        if(!$file->exists())
        {
            $original = $this->files->projectVideoScreenshot($projectId, $storageName);

            if($original->exists())
            {
                $tmpImg = tempnam(TEMP_PATH, 'img');
                $original->saveToFile($tmpImg);

                ImageManager::make($tmpImg)
                    ->resize($width, $height, function ($constraint)
                    {
                        $constraint->aspectRatio();
                        $constraint->upsize();
                    })
                    ->save($tmpImg)
                    ->destroy();

                $newImage = $this->files->projectVideoScreenshot($projectId, $storageName, $width, $height);
                $newImage->loadFromFile($tmpImg);

                return $newImage->getLink();
            }
        }
        else
        {
            return $file->getLink();
        }
        return null;
    }
}

0 个答案:

没有答案