致命錯誤: Class 'app\facade\Test' not found
Blue
Blue 2019-10-17 21:33:48
0
3
1719

[0] ThrowableError in Demo2.php line 28

致命錯誤: Class 'app\facade\Test' not found

#        * __call 當要呼叫的方法不存在或
        * __call 權限的方法不存在或

 時,會自動呼叫__call 方法。        *__callStatic 當呼叫的靜態方法不存在或權限不足時,會自動呼叫__callStatic方法。 *  方式一,在app\facade\Test定義protected static function getFacadeClass()         *  使用app\facade\Test 代理程式了app\common\Test         * 如果沒有在靜態代理類別中顯示要指定為綁定的類別動態顯示綁定\think\Facade::bind();         * 方式二不需要在此定義(app\facade\Test ),跟框架自帶模板類似,使用\think\Facade::bind('app\ facade\Test', 'app\common\Test');         **/        \think\Facade::bind('app\facade\Test','app\common\Test'); :hello('today');    }}



原始碼

   public function index($name = 'WQ')
   {
//        $test = new \app\common\Test();
//        return $test->hello();        return $test->hello();   //此方式為動態方式存取 //


       /**
        *以靜態方式存取。靜態方式呼叫一個動態方法
        *需要給該類別綁定一個靜態代理的類,給一個靜態馬甲
        * __callStatic($method,$params){…}
    * __callStatic($method,$params){…}
    __ c的方法不存在或權限不足時,會自動呼叫__call 方法。
        *__callStatic 當呼叫的靜態方法不存在或權限不足時,會自動呼叫__callStatic方法。
        *  方式一,在app\facade\Test定義protected static function getFacadeClass()
        *  使用app\facadeTest 代理程式顯示了 appnmonmon\Test#common 要綁定的類別名,就需要動態顯示綁定\think\Facade::bind();
        * 方式二不需要在此定義(app\facade\Test ),跟框架自帶模板類似,使用\think\Facade::bind('app\facade\Test', 'app\common\Test');
        **/

       \think\Facade::bind('app\facade\Test','app\common\Test');##\ #        return \app\facade\Test::hello('today is beatiful day!');

   }###
Blue
Blue

全部回覆(2)
小萝卜头

這是咋回事啊大哥  老師說的有點深奧 沒懂

Peter-Zhu

給不存在Facade的類別, 按框架的規則, 可以自訂它的門面

  • 回覆 多謝 問題已經解決。
    Blue 作者 2019-10-20 09:53:13
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!