Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class 'PDFMerger\PDFMerger' not found in Laravel #34

Open
christiancannata opened this issue Jun 13, 2018 · 7 comments
Open

Class 'PDFMerger\PDFMerger' not found in Laravel #34

christiancannata opened this issue Jun 13, 2018 · 7 comments

Comments

@christiancannata
Copy link

Hi guys,
after downloaded package with composer, I got this error when I try to create new PDFMerger object.

in vendor there is the folder with class and namespace correctly.

@humblecoder
Copy link

Same here, even in "bare bones" PHP app with properly configured autoload.php

@jiwom
Copy link

jiwom commented Oct 30, 2019

Error also occur using Laravel 5.2. Installed using
composer require myokyawhtun/pdfmerger:dev-master

@swetaranjan7
Copy link

Found any solution for above issue? Even I am getting this issue for drupal.

@myokyawhtun
Copy link
Owner

@christiancannata @humblecoder @jiwom @swetaranjan7

I'm sorry that I was far away from github. Below is the working example

require_once ('PDFMerger/PDFMerger.php');

use PDFMerger\PDFMerger;
$pdf = new PDFMerger;

$pdf->addPDF('a.pdf');
$pdf->addPDF('b.pdf');

$pdf->merge('download','merged.pdf');

@PrabhavPanta
Copy link

main(): Failed opening required 'PDFMerger/PDFMerger.php' (include_path='.;C:\php\pear')

getting this error after installing through composer and using the namespace as mentioned above

@matiasmancilla
Copy link

same

@chinlung
Copy link

chinlung commented Feb 10, 2022

For my case, simply add the declaration in composer.json as follows.

"autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/",
            "PDFMerger\\": "vendor/myokyawhtun/pdfmerger/" <----- add this line
        }
    },

Then, don't need to declare

require_once ('PDFMerger/PDFMerger.php');
use PDFMerger\PDFMerger;

Just .....

$pdf = new \PDFMerger\PDFMerger;

$pdf->addPDF('a.pdf');
$pdf->addPDF('b.pdf');

$pdf->merge('download','merged.pdf');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants