Proof-of-concept PHP extension linking pdf-core-c
via its C shared library (libpdf_core_c.dylib). Exposes the ripper PDF API as native
PHP objects — demonstrating the ripper vision: write the core once in C++, build the
C API, then bind to any language.
Ripper\PDF\Core\Document
- PHP 8.3+
phpize(dev headers)- macOS (
.dylib) or Linux (.so)
cd pdf-core-php
make buildThis runs phpize, ./configure, and make — producing modules/ripper.so.
<?php
$doc = new Ripper\PDF\Core\Document('input.pdf', 'output.pdf');
echo $doc->pageCount() . "\n"; // 3
$doc->addPage();
echo $doc->pageCount() . "\n"; // 4
$doc->removePage(0);
echo $doc->pageCount() . "\n"; // 3
$doc->save();
// All errors from the C layer throw \ExceptionsRun with:
php -d extension=modules/ripper.so script.php| Method | Returns | C API binding |
|---|---|---|
__construct |
— | rip_pdf_document_open_for_edit |
pageCount() |
int |
rip_pdf_document_page_count |
addPage() |
void |
rip_pdf_document_add_page |
removePage(int) |
void |
rip_pdf_document_remove_page |
save() |
void |
rip_pdf_document_save |
pdf-core-php/
├── config.m4 # PHP extension build config
├── Makefile # Convenience wrapper (make build / test / clean)
├── README.md
├── ripper_pdf_core.h # Public header — includes internals
├── src/
│ ├── ripper.c # Extension entry point
│ ├── ripper_internal.h # Internal umbrella header
│ ├── document.c # Document class implementation
│ └── error.c # Centralized error handling
├── include/
│ └── ripper/
│ ├── error.h # Error handling declarations
│ └── pdf/core/
│ └── document.h # Document class declarations
├── lib/ # Shared library bundle
│ ├── libpdf_core_c.dylib
│ └── libz.1.dylib
└── test.php