2013-11-28 57 views

回答

2

比方說,你希望把定製的插件/應用/插件/自定義/ lib文件夾的例外:

// Location: /app/Plugin/Custom/Lib/CustomException.php 
<?php 
class CustomException extends CakeException {}; 

現在你需要加載自定義插件在/app/Config/bootstrap.php:

// Location: /app/Config/bootstrap.php 
CakePlugin::load('Custom'); 

而且,無論你想使用CustomException

<?php 
App::uses('CustomException', 'Custom.Lib'); 

class ApiController extends AppController { 

    public function demo() { 
     throw new CustomException("Just testing"); 
    } 

} 
相關問題