I ran this call in Putty
, it successfully installed the resource:
php composer.phar require --dev "mikehaertl/php-pdftk:*"
I then added a couple of thing to my composer.json
:
{
"name": "you/bootstrap-canvas-wp",
"type": "wordpress-theme",
"require": {
"composer/installers": "~1.0"
},
"require-dev": {
"mikehaertl/php-pdftk": "*"
},
"extra": {
"installer-paths": {
"wp-content/themes/bootstrap-canvas-wp/": ["type:wordpress-theme"]
}
}
}
Next I ran an update
command on my composer file:
php composer.phar update
I have a file located inside that theme folder /public_html/wp-content/themes/bootstrap-canvas-wp
that has this code:
use \mikehaertl\pdftk\Pdf;
$pdf = new Pdf('mypdf.pdf');
$pdf->flatten()
->saveAs('mypdf2.pdf');
Finally, I placed this piece of code in my functions.php
file inside the theme folder in an effort to make these classes usable:
require_once(ABSPATH. '../vendor/autoload.php');
My code editor recognizes these resources but I get an error in my browser:
Fatal error: Class 'mikehaertl\pdftk\Pdf' not found in /home/myusername/public_html/wp-content/themes/bootstrap-canvas-wp/flattenPDF.php on line 1
Any suggestions on how to make this functional?
EDIT: I've also tried this syntax for the use
statement: (same error happens)
use mikehaertl\pdftk\Pdf;
I got the same error when autoload was not called correctly. What solved for me is:
I use this in plain php project,the php page where i use it it is the same folder as the mikehaertl folder. So i am sure that your issue is related to this