2017-12-19 12 views

답변

0

, 다음 명령을 실행

composer require ingenico-epayments/connect-sdk-php 

다음, 당신은 CodeIgniter의 자동로드 작곡가 패키지를 갖고 싶어합니다 config/config.php 파일에서 너무 :

$config['composer_autoload'] = TRUE; 

이제 작곡가 패키지를 사용할 수 있습니다. 즉 컨트롤러 또는 모델에서 다음과 같이 할 수 있습니다 (컨트롤러에서 사용하고 있습니다).

<?php 

use \Ingenico\Connect\Sdk\CommunicatorConfiguration; 
use \Ingenico\Connect\Sdk\DefaultConnection; 
use \Ingenico\Connect\Sdk\Communicator; 
use \Ingenico\Connect\Sdk\Client; 

class Test extends CI_Controller { 

    public function __construct(){ 
     parent::__construct(); 
    } 

    /** 
    * This is an example of basic usage from 
    * https://epayments.developer-ingenico.com/documentation/sdk/server/php/ 
    */ 
    public function index() 
    { 
     $communicatorConfiguration = 
      new CommunicatorConfiguration('ApiKeyId', 'ApiSecret', 'BaseUri', 'Integrator'); 
     $connection = new DefaultConnection(); 
     $communicator = new Communicator($connection, $communicatorConfiguration); 

     $client = new Client($communicator); 

     // Do something with $client ... 
    } 
} 

use 문이 클래스 위에 어떻게 위치하는지 알 수 있지만 네임 스페이스는 없습니다. 일반적으로 CodeIgniter에서는 자신의 라이브러리 또는 third_party 클래스가 아닌 한 네임 스페이스가 없습니다. 네임 스페이스가 없으므로 use 문을 사용하면 Ingenico 클래스 앞에 \ Ingenico \ Connect \ Sdk를 붙이는 대신 Ingenico 클래스를 이름으로 사용하도록 알립니다. 당신이 행복하게한다면 use 문 대신 접두어를 사용할 수 있습니다.

+0

예, 잘 작동합니다. 감사합니다, @ 브라이언 Gottier. –