在Composer中缺少Mustache_Autoloader [英] Mustache_Autoloader missing with Composer

查看:82
本文介绍了在Composer中缺少Mustache_Autoloader的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Composer下载了最后的胡子(2.7)版本

I dowload the last versión of Mustache (2.7) with Composer,

"require": {
        "mustache/mustache" : "2.7.*",
        // etc...
 }

但是当我尝试:

use Mustache\Mustache_Autoloader;

abstract class BaseController {
    public function __construct() {
        Mustache_Autoloader::register();
        /...
   }
   /...
}

error.log说:

the error.log said:

PHP Fatal error:  Class 'Mustache\\Mustache_Autoloader' not found in 

尽管,Mustache_Autoloader没有命名空间.

Although, Mustache_Autoloader hasn't namespaces.

作曲家有:composer/autoload_namespaces.php:

 return array(
        'Mustache' => array($vendorDir . '/mustache/mustache/src'),
        //etc 
    );

在我的主文件中,我没有忘记包含require 'vendor/autoload.php';,但是我不知道发生了什么.任何的想法?谢谢.

And in my main file I don't forget include require 'vendor/autoload.php'; But I don't know what happend. Any idea? Thanks.

解决方案:

只需要在单词的开头添加"\"即可.像new \Mustache_Engine().

Only I need to add '\' at the beginning of the word. like new \Mustache_Engine().

现在可以使用了.感谢您的帮助:)

Now it works. Thanks for your help :)

推荐答案

首先,为什么要使用Mustache\Mustache_Autoloader? 作曲家应注意自动加载.

First, why do you want to use the Mustache\Mustache_Autoloader ? composer should take care of the autoloading.

我进一步在 https://github中看到. com/bobthecow/mustache.php/blob/master/src/Mustache/Autoloader.php 该类没有名称空间.
因此use Mustache\Mustache_Autoloader;失败.

Further i see in https://github.com/bobthecow/mustache.php/blob/master/src/Mustache/Autoloader.php that this class has no namespace.
Therefor use Mustache\Mustache_Autoloader; fails.

如果要使用自动装带器,则最好使用:
require '/path/to/mustache/src/Mustache/Autoloader.php'; Mustache_Autoloader::register();.

If you want to use the autoloader you better use:
require '/path/to/mustache/src/Mustache/Autoloader.php'; Mustache_Autoloader::register();.

这篇关于在Composer中缺少Mustache_Autoloader的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆