【发布时间】:2015-07-01 21:03:45
【问题描述】:
我目前遇到了 Laravel (5) 的问题,自从 4 的早期版本以来,我已经很长时间没有接触过 laravel,而 Laravel 5 一发布我就登上了火车,以为我会尝试一下,特别是使用表情短语。
基本上我遇到的总体问题是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>'),
)
);
【问题讨论】:
-
尝试更改为
namespace App\Libs;。