콘텐츠로 이동

NextPDF CodeIgniter 통합

패키지를 설치하면 CodeIgniter 4가 자동으로 연결합니다. 이 페이지는 통합 참조 문서입니다. 검색, 바인딩 모델, 구성 게시, 통합이 작동함을 입증하는 단일 메서드 스모크 테스트를 다룹니다.

Terminal window
composer require nextpdf/codeigniter

서비스 프로바이더를 편집하지 않으며 부트스트랩 파일도 변경하지 않습니다. 검증된 버전 제약 조건은 /integrations/codeigniter/install/에서 확인하세요.

CodeIgniter 4는 Composer 패키지 검색을 통해 패키지를 찾습니다. 이는 프레임워크 기본값인 Config\Modules::$discoverInComposertrue일 때 동작합니다. PSR-4 접두사 NextPDF\CodeIgniter\src/CodeIgniter/에 매핑됩니다. 이 매핑을 통해 프레임워크는 NextPDF\CodeIgniter\Config\Services를 해당 파일로 확인합니다(PSR-4 §x1.x3). /integrations/codeigniter/boot-and-discovery/는 전체 시퀀스와 이를 제어하는 Config\Modules 속성을 문서화합니다.

CodeIgniter 4에는 PSR-11 컨테이너가 포함되어 있지 않습니다. PSR-11 §1.3은 서비스 로케이터 패턴을 권장하지 않습니다(SHOULD NOT 수준). 패키지는 프레임워크의 로케이터 규칙을 따르되 사용 범위는 최소로 유지합니다. 각 바인딩은 bool $getShared 매개변수를 갖는 하나의 명명된 정적 팩토리입니다.

서비스 이름반환 값기본 수명
fontRegistryFontRegistryInterface공유
imageRegistryImageRegistry공유
documentFactoryDocumentFactoryInterface공유
pdfDocumentDocument새로 생성
pdfPdf새로 생성
tsaClient?TsaClient공유
pdfSigner?SignerInterface새로 생성

두 진입점 중 어느 쪽으로도 확인할 수 있으며, 둘은 동등합니다.

<?php
declare(strict_types=1);
use NextPDF\CodeIgniter\Config\Services;
$a = Services::pdf(false); // direct
$b = \service('pdf'); // helper → Services::pdf()

전역 헬퍼인 pdf()pdf_document()Services::pdf(false)Services::pdfDocument(false)를 감싸는 얇은 래퍼입니다.

패키지 구성은 NextPDF\CodeIgniter\Config\NextPdf에 있으며, 이 클래스는 non-final BaseConfig입니다. 이를 재정의하는 공식 지원 방법은 두 가지입니다.

1. 클래스 확장 (타입이 지정되고 버전 관리됩니다). app/Config/NextPdf.php를 생성합니다.

<?php
declare(strict_types=1);
namespace Config;
use NextPDF\CodeIgniter\Config\NextPdf as BaseNextPdf;
final class NextPdf extends BaseNextPdf
{
public int $imageCacheMb = 100;
}

CodeIgniter는 패키지 기본값 대신 애플리케이션 클래스를 로드합니다.

2. .env로 재정의 (환경별). 접두사는 소문자 짧은 클래스 이름인 nextpdf입니다.

nextpdf.imageCacheMb = 100
nextpdf.signature.enabled = true
nextpdf.signature.certificate = /etc/nextpdf/cert.pem

/integrations/codeigniter/configuration/에는 모든 키와 배열 재정의 규칙이 문서화되어 있습니다.

서비스 프로바이더 / 번들 스모크 테스트

섹션 제목: “서비스 프로바이더 / 번들 스모크 테스트”

CodeIgniter에는 테스트할 서비스 프로바이더나 번들 클래스가 없습니다. 따라서 이에 상응하는 스모크 테스트는 두 가지를 확인합니다. 검색이 서비스를 확인했는지, 그리고 수명이 지정된 대로 동작하는지입니다. 아래 테스트는 패키지 자체의 기능 어설션을 반영한 실행 가능한 컨트롤러 액션입니다.

<?php
declare(strict_types=1);
namespace App\Controllers;
use CodeIgniter\HTTP\ResponseInterface;
use NextPDF\CodeIgniter\Config\Services;
use NextPDF\CodeIgniter\Libraries\Pdf;
use NextPDF\Core\Document;
final class NextPdfSmokeController extends BaseController
{
public function check(): ResponseInterface
{
// Discovery resolved the services.
$document = Services::pdfDocument(false);
$library = Services::pdf(false);
// Documents are fresh per call (no cross-request leakage).
$freshIsolated = Services::pdfDocument(false) !== $document;
// Registries are shared singletons.
$registrySingleton = Services::fontRegistry() === Services::fontRegistry();
// Optional services degrade to null without Premium / TSA config.
$signerOptional = Services::pdfSigner(false) === null;
$ok = $document instanceof Document
&& $library instanceof Pdf
&& $freshIsolated
&& $registrySingleton
&& $signerOptional;
return $this->response
->setStatusCode($ok ? 200 : 500)
->setJSON([
'discovery' => $document instanceof Document,
'document_fresh_per_call' => $freshIsolated,
'registry_shared' => $registrySingleton,
'signer_optional_null' => $signerOptional,
]);
}
}

이 액션에 라우트를 매핑한 뒤 요청합니다. 200 응답에서 모든 플래그가 true로 설정되면 통합이 입증됩니다. 여기의 각 어설션은 패키지의 기능 테스트 스위트에서 검증된 동작과 일치합니다.

  • 호스트 애플리케이션이 Composer 검색을 꺼 둔 경우 nextpdf/codeigniterConfig\Modules::$composerPackages['only']에 추가합니다.
  • Services::pdfDocument(true)는 공유 문서를 반환합니다. 이 동작은 테스트 재설정 용도로만 존재합니다. 요청 또는 작업 코드에서 공유 문서를 절대 요청하지 마세요.
  • Services::pdfSigner()Services::tsaClient()는 서명 또는 TSA URL이 구성될 때까지 null을 반환합니다. 이는 의도된 graceful degradation 동작이며, 실패가 아닙니다.
  • 모듈 검색을 위한 클래스 경로 매핑(PSR-4 Autoloader §x1.x3).
  • 바인딩 모델을 위한 서비스 로케이터 지침(PSR-11 Container §1.3).

NextPDF 코어는 Apache-2.0입니다. Pro 및 Enterprise 서비스는 설치되면 동일한 Services 표면에 나타납니다. CodeIgniter 패키지는 이에 대응하는 서비스 메서드를 노출합니다. 각 메서드는 대응하는 Premium 패키지가 설치될 때까지 null을 반환합니다. </get-license/?를 참조하세요.intent=codeigniter>.

  • /integrations/codeigniter/boot-and-discovery/ — 검색의 내부 동작.
  • /integrations/codeigniter/install/ — 버전 제약 조건 및 검증.
  • /integrations/codeigniter/quickstart/ — 첫 번째 PDF.
  • /integrations/codeigniter/production-usage/ — DI로 연결된 컨트롤러 및 큐 작업.
  • /integrations/codeigniter/configuration/ — 모든 구성 키.