2014-03-25 55 views
0

我試圖位於app/helpers一個文件夾中使用Laravel 4一個輔助類,但無論我做什麼Laravel給我的錯誤Class was not foundLaravel 4 Helper類不會自動加載

助手基類

Helper.php 
<?php 
/* 
    Base Helper class! 
*/ 

class Helpers { 

} 

類想要使用

<? 
class Gravatar extends Helpers { 
/** 
    * Get either a Gravatar URL or complete image tag for a specified email address. 
    * 
    * @param string $email The email address 
    * @param string $s Size in pixels, defaults to 80px [ 1 - 2048 ] 
    * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ] 
    * @param string $r Maximum rating (inclusive) [ g | pg | r | x ] 
    * @param boole $img True to return a complete IMG tag False for just the URL 
    * @param array $atts Optional, additional key/value attributes to include in the IMG tag 
    * @return String containing either just a URL or a complete image tag 
    * @source http://gravatar.com/site/implement/images/php/ 
    */ 
    public static function get_gravatar($email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts = array()) { 
     $url = 'http://www.gravatar.com/avatar/'; 
     $url .= md5(strtolower(trim($email))); 
     $url .= "?s=$s&d=$d&r=$r"; 
     if ($img) { 
      $url = '<img src="' . $url . '"'; 
      foreach ($atts as $key => $val) 
       $url .= ' ' . $key . '="' . $val . '"'; 
      $url .= ' />'; 
     } 
     return $url; 
    } 
} 

這是我嘗試訪問功能的類在刀片文件:

<img src="{{ Gravatar::get_gravatar($thread['user']['email'], 50) }}"> 

我已經包含在global.php和composer.json的文件夾。我也嘗試運行composer dump-autoload無濟於事。

我該如何解決這個問題?

回答

0

發現問題。

在Gravatar.php中<?應該是<?php現在它的工作原理!