未找到“App \ Libs \ Emotes”类(Laravel& Blade)

时间:2015-07-01 21:03:45

标签: php laravel blade

我目前正在与Laravel(5)发生一个问题,自从早期版本的4版本以来我没有触及laravel已经有很长一段时间了,而且一旦Laravel 5发布,我就登上了火车并认为我会有它,特别是Emote phraser。

基本上我遇到的总体问题是Class "App\Libs\Emote is not found",虽然我认为我已经为我们正确注册了别名,但有人可能证明我错了。

<!DOCTYPE html>
<html>
    <head>
        <title>Laravel</title>

        <link href="//fonts.googleapis.com/css?family=Lato:100" rel="stylesheet" type="text/css">

        <style>
            html, body {
                height: 100%;
            }

            body {
                margin: 0;
                padding: 0;
                width: 100%;
                display: table;
                font-weight: 100;
                font-family: 'Lato';
            }

            .container {
                text-align: center;
                display: table-cell;
                vertical-align: middle;
            }

            .content {
                text-align: center;
                display: inline-block;
            }

            .title {
                font-size: 96px;
            }
        </style>
    </head>
    <body>
        <div class="container">
            {{
                Emote::PhraseEmote()
            }}
            <div class="content">
                <div class="title">(flag:gb) (flag:us)</div>
            </div>
        </div>
    </body>
</html>


Class;

<?php
namespace Libs\Emotes;

class Emotes {

    public static function PhraseEmote($value) {
        $config = Config::get('emotes');

        $smileys = $config['render_phrase'];

        foreach($emotes as $key => $val) {
            //$value = str_replace($key, '<img src="' . $config['path'] . $smileys[$key][0] . '" width="' . $smileys[$key][1] . '" height="' . $smileys[$key][2] . '" alt="' . $smileys[$key][3] . '" style="border:0;" />', $value);
            $value = str_replace($key, $emotes[$key][0], $value);
        }

        return $value;
    }
}
?>

Config;

<?php
return array(
    'render_phrase'    => array(
        '(flag:gb)' => array('<i class="gb flag" data-content="United Kingdom" data-variation="tiny"></i>'),
        '(flag:us)' => array('<i class="us flag" data-content="United States" data-variation="tiny"></i>'),
        //'(flag:CN_Code)' => array('<i class="CN_CODE flag" data-content="United States" data-variation="tiny"></i>'),
    )
);

1 个答案:

答案 0 :(得分:0)

看到你的文件夹结构后,我认为这可能会有所帮助。

名称空间是类的基本目录(路径)。所以

namespace App\Libs\EmoteLib

由于你的课程没有扩展任何课程,你现在很乐意去。

希望它有所帮助。