PHP 5.5+ samples project
The PHP 5.5+ samples project shows how to use Rest PKI together with Web PKI on a project using PHP 5.5+ (including 7.x). It is hosted on GitHub at:
https://github.com/LacunaSoftware/RestPkiSamples/tree/master/PHP/standard
Note
For projects targeting earlier PHP versions, click here.
Running the project
- Download the project or clone the repository
- Generate an API access token on the REST PKI website
- Paste your access token on the file PHP/standard/config.php
- In a command prompt, navigate to the folder
PHP/standard
and run the commandcomposer install
to download the dependencies (if you don't have Composer installed, get it here) - Setup a website on your local HTTP server pointing to the
PHP/standard
folder - Open the index.php file on the browser on the corresponding URL (depending on the previous step)
Project map
This section lists where to find the relevant parts in each feature sample on the project.
Authentication with digital certificate
PAdES signature with file already on server
PAdES signature with file uploaded by user
After the file upload (which is crudely implemented merely for demonstration purposes on
upload.php)
is done the control flow is the same as in the sample PAdES signature with file already on server, but with the URL parameter userfile
filled.
PAdES co-signature
After the control flow of the sample PAdES signature with file already on server is completed and the link Co-sign with another certificate is clicked, the
same control flow is repeated, but now with the URL parameter userfile
filled.
PAdES marks
This feature is demonstrated as an optional configuration on the PAdES signature with file already on server sample which by default starts commented out. To enable it, uncomment the following line on pades-signature.php:
array_push($signatureStarter->pdfMarks, getPdfMark(1));
Tip
Try changing the argument to the getPdfMark()
function to see different PDF mark configurations
The relevant code is on the file util-pades.php, function getPdfMark()
.
PAdES signature using server key
pades-signature-server-key.php
PAdES signature without client communication
Not yet available on this project.
Open/validate an existing PAdES signature
Printer-friendly version
After the control flow of the sample PAdES signature with file already on server is completed and the link Download a printer-friendly version of the signed file is clicked,
the flow goes to the file
printer-friendly-version.php
with the URL parameter file
filled.
The generated PDF contains links to the file check.php, which shows details of the signatures.
CAdES signature with file already on server
CAdES signature with file uploaded by user
After the file upload (which is crudely implemented merely for demonstration purposes on
upload.php)
is done the control flow is the same as in the sample CAdES signature with file already on server, but with the URL parameter userfile
filled.
CAdES co-signature
After the control flow of the sample CAdES signature with file already on server is completed and the link Co-sign with another certificate is clicked, the
same control flow is repeated, but now with the URL parameter cmsfile
filled.
CAdES signature using server key
Open/validate an existing CAdES signature
XML signature of the entire document
XML signature of an element
XAdES signature of an element
Not yet available on this project.
Open/validate signatures on an existing XML file
Batch of PAdES signatures
- batch-signature.php
- JavaScript: batch-signature-form.js
- AJAX handlers: batch-signature-start.php and batch-signature-complete.php
Optimized batch of PAdES signatures
Not yet available on this project.
Batch of CAdES signatures
Not yet available on this project.