Setasign / FPDI

FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF.
https://www.setasign.com/fpdi
MIT License
1.09k stars 159 forks source link

Cannot found FPDI class/ Composer error #53

Closed Telsho closed 6 years ago

Telsho commented 6 years ago

Hello !

I've an issue with FPDI, as the title says it's about the class FPDI : "Fatal error: Class 'fpdi\FPDI' not found in C:\"

My code is the following :

` require_once('fdpi/vendor/autoload.php'); require_once('fdpi/src/autoload.php');

use fpdi\FPDI;

$pdf = new FDPI(); $pdf->AddPage();`

I haven't seen any solution on internet.. Thanks !

EDIT: I realized that I had to add : { "require": { "setasign/fpdf": "^1.8", "setasign/fpdi": "^2.0" } } into the composer file if I want to use FPDF in the same time, and thats what I did, but now I've an issue with the composer, I tried to remove everything but the error is still remaining.

  • The requested package setasign/fpdi No version set (parsed as 1.0.0) is satisfiable by setasign/fpdi[No version set (parsed as 1.0.0)] but these conflict with your requirements or minimum-stability.
JanSlabon commented 6 years ago

The namespace of FPDI is \setasign\Fpdi.

Please read through the documentation and check out the examples.

The error message from composers looks somewhat strange to me. Please follow the installation guide of the documentation.

Telsho commented 6 years ago

I've tried several things, even to use it on a linux machine but I still get the same error.. I want to use FPDF with it, then I've add the line { "require": { "setasign/fpdi-fpdf": "^2.0" } }

My error is now :

Problem 1

  • Installation request for setasign/fpdi No version set (parsed as 1.0.0) -> satisfiable by setasign/fpdi[No version set (parsed as 1.0.0)].
  • setasign/fpdi-fpdf v2.0.0 requires setasign/fpdi ^2.0 -> satisfiable by setasign/fpdi[v2.0.0, v2.0.1, v2.0.2, v2.0.3].
  • Can only install one of: setasign/fpdi[v2.0.0, No version set (parsed as 1.0.0)].
  • Can only install one of: setasign/fpdi[v2.0.1, No version set (parsed as 1.0.0)].
  • Can only install one of: setasign/fpdi[v2.0.2, No version set (parsed as 1.0.0)].
  • Can only install one of: setasign/fpdi[v2.0.3, No version set (parsed as 1.0.0)].
  • Installation request for setasign/fpdi-fpdf ^2.0 -> satisfiable by setasign/fpdi-fpdf[v2.0.0].

And my composer.json looks like this, maybe I've put it on the wrong place ? { "name": "setasign/fpdi", "homepage": "https://www.setasign.com/fpdi", "description": "FPDI is a collection of PHP classes facilitating developers to read pages from existing PDF documents and use them as templates in FPDF. Because it is also possible to use FPDI with TCPDF, there are no fixed dependencies defined. Please see suggestions for packages which evaluates the dependencies automatically.", "type": "library", "keywords": [ "pdf", "fpdi", "fpdf" ], "license": "MIT", "autoload": { "psr-4": { "setasign\\Fpdi\\": "src/" } }, "require": { "php": "^5.6 || ^7.0", "ext-zlib": "*" }, "authors": [ { "name": "Jan Slabon", "email": "jan.slabon@setasign.com", "homepage": "https://www.setasign.com" }, { "name": "Maximilian Kresse", "email": "maximilian.kresse@setasign.com", "homepage": "https://www.setasign.com" } ], "suggest": { "setasign/fpdf": "FPDI will extend this class but as it is also possible to use \"tecnickcom/tcpdf\" as an alternative there's no fixed dependency configured.", "setasign/fpdi-fpdf": "Use this package to automatically evaluate dependencies to FPDF.", "setasign/fpdi-tcpdf": "Use this package to automatically evaluate dependencies to TCPDF." }, "require-dev": { "phpunit/phpunit": "~5.7", "setasign/fpdf": "~1.8", "tecnickcom/tcpdf": "~6.2" }, "autoload-dev": { "psr-4": { "setasign\\Fpdi\\": "tests/" } }, "require": { "setasign/fpdi-fpdf": "^2.0" } }

Thanks a lot for your help !

JanSlabon commented 6 years ago

Why do you use the composer.json of FPDI?

For sure you need to create your own: https://getcomposer.org/doc/01-basic-usage.md !

Telsho commented 6 years ago

Oh I see, the thing is this is the first time I'm using composer and I don't get all of it..

Where should I put the composer.json file ? Should I rewrite the one from FPDI and then use autoload instead of doing composer install ?

JanSlabon commented 6 years ago

Don't get me wrong but this is not a support forum for "how to use composer". If you're not familiar with it, ask in an appropriate forum or use FPDI without composer.