require_once不起作用 - 在Zend Framework动作方法中

时间:2014-12-24 22:35:34

标签: php zend-framework require-once

我需要将Authorize.net支付网关集成到我的Zf2应用程序中。 在php include路径下载并复制PHP SDK。 sdk有以下文件

+authoriznet
        +doc
        +lib
            +shared
            +ssl
            -AuthorizeNetSIM.php (and more)
        -AuthorizeNet.php  

我的代码(Zend控制器)是

require_once 'path/AuthorizeNet.php'; /*This require_once AuthorizeNetSIM.php and other files)*/

class PurchaseController extends AbstractActionController{

     public purchaseAction(){
        $works = new AuthorizeNetException("test"); //A class defined in AuthorizeNet.php
        $notFound = new AuthorizeNetSIM;  
     }
}

$ works - >工作得很好,因为$ notFound抛出类未找到异常

如果我在视图文件(.phtml)中添加require_once,则可以使用sdk中的所有类。

有人可以解释这种行为吗?如何在Zf2中正确使用这个第三方库?

0 个答案:

没有答案