Search code examples
phpcomposer-phpezpdf

Warning: include(xxxx): failed to open stream: No such file or directory


I'm having a problem regarding using composer with ros/ezpdf

This is my file structure

home
    --miga
            --db
                --file.php
            --vendor
                --ros
                    --ezpdf
                        --src
                            --Cezpdf.php
        composer.json

in my main file i have this

error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', '1');
require_once "dbconfig.php";
require_once __DIR__ . '/../vendor/autoload.php';
include '../vendor/ros/ezpdf/src/Cezpdf.php';
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
setlocale(LC_ALL, NULL);
setlocale(LC_ALL, 'pt_PT');

and my composer.json this:

"autoload": {
  "classmap": ["db/class.esmaior.php"],
  "files": ["src/Cpdf.php", "src/Cezpdf.php"]

},
"require": {
  "phpmailer/phpmailer": "6.0.x-dev",
  "ros/ezpdf": "0.12.1"
}

If i use this

include '../vendor/ros/ezpdf/src/Cezpdf.php';

The pdf is created but in every pages of my website i have those warnings

Warning: include(../vendor/ros/ezpdf/src/Cpdf.php): failed to open stream: No such file or directory in

and if i remove the line i have this error

Fatal error: Class 'Cezpdf' not found in /home/xxxx/public_html/miga/db/class.esmaior.php on line 2910


Solution

  • Try this include(__DIR__."/../vendor/ros/ezpdf/src/Cezpdf.php");