1

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

  • When using autoload, you shouldn't use require for each class. Autoload should do this for you. https://getcomposer.org/doc/01-basic-usage.md#autoloading – Felippe Duarte Jan 19 '17 at 15:00
  • i i don't use require...Fatal error: Class 'Cezpdf' not found in /home/xxxx/public_html/miga/db/class.esmaior.php on line 2910 –  Jan 19 '17 at 15:01

1 Answers1

0

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

Kenziiee Flavius
  • 1,918
  • 4
  • 25
  • 57