mpdf / mpdf

PHP library generating PDF files from UTF-8 encoded HTML
https://mpdf.github.io
GNU General Public License v2.0
4.37k stars 1.06k forks source link

autoload_files bug ? #763

Closed Matkill closed 6 years ago

Matkill commented 6 years ago

Hi,

I used mpdf 7.1.0 and i'm using codeigniter. I used the composer.json file from the zip file, i put it in my project folder and everything is installed correctly (vendor folder created and all the required sub-folders created) except mpdf.

Here the output console when i used composer (to show you all good): `PS C:\wamp64\www\xxx> composer require mpdf/mpdf Using version ^7.1 for mpdf/mpdf ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 33 installs, 0 updates, 0 removals

When i include MPDF in my code i have the following error: `A PHP Error was encountered

Severity: Warning

Message: require(C:\wamp64\www\xxx\application\vendor\composer/../../src/functions-dev.php): failed to open stream: No such file or directory

Filename: composer/autoload_real.php

Line Number: 69

Backtrace:

File: C:\wamp64\www\xxx\application\vendor\composer\autoload_real.php Line: 69 Function: _error_handler

File: C:\wamp64\www\xxx\application\vendor\composer\autoload_real.php Line: 69 Function: require

File: C:\wamp64\www\xxx\application\vendor\composer\autoload_real.php Line: 56 Function: composerRequireeab037956fe0dda50dc5cde99c31727b

File: C:\wamp64\www\xxx\application\vendor\autoload.php Line: 7 Function: getLoader

File: C:\wamp64\www\xxx\index.php Line: 315 Function: require_once`

i double checked and the problem is inside the autoload_files.php file under "vendo\composer\". there is the following code inside: `<?php

// autoload_files.php @generated by Composer

$vendorDir = dirname(dirname(FILE)); $baseDir = dirname($vendorDir);

return array( '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php', '1d1b89d124cc9cb8219922c9d5569199' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest.php', '6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php', '5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php', '7745382c92b7799bf1294b1f43023ba2' => $vendorDir . '/tracy/tracy/src/shortcuts.php', 'bdffba51b95e502d380f6113430270a2' => $baseDir . '/src/functions-dev.php', );`

$vendorDir = the vendor folder so all good. But for any reasons, for the last file required it is looking in $basedir. I checked this variable and this is the folder "applications". So i don't have any src folder inside the application folder.

I took the "src" folder from the mpdf archive and i put it inside the "application" folder and now it is working.

My question is : is it a bug or maybe i did something wrong in using the composer file ?

Matkill commented 6 years ago

If i want to have a dedicated folder for mpdf, like "vendor/mpdf/xxx" (because as i said, mpdf is not created with composer for an unknown reason, and i have to put the "src" and "data" folder directly under the "applications" folder of Codeigniter) i have to modify the "autoload_static.php" and change the relative path for 2 variables:

'bdffba51b95e502d380f6113430270a2' => DIR . '/../..' . '/src/functions-dev.php' changed to ===> 'bdffba51b95e502d380f6113430270a2' => DIR . '/../..' . '/vendor/mpdf/src/functions-dev.php'

and

'Mpdf\' => array ( 0 => DIR . '/../..' . '/src', 1 => DIR . '/../..' . '/tests/Mpdf', ),

changed to ===>

'Mpdf\' => array ( 0 => DIR . '/../..' . '/vendor/mpdf/src', 1 => DIR . '/../..' . '/tests/Mpdf', ),

With that it is working... maybe i've done something wrong with composer but i don't think. This is the only package where i had this problem.

finwe commented 6 years ago

Why are you even using some archive? All you should need to do is to run

composer require mpdf/mpdf

in your codeigniter project. No copying files manually.

Seems to me you are just using composer incorrectly.