I want to use TCPDF library in my ZF2 project. I have the source of library but it is incompatible with Zend Framework 2 namespace (not PSR-0). How to include it in the project? If there are any way to convert it with ZF2 compatible.
If there is a way to use the library as it is then please show the process (where to place library source and how to include it).
Please do not suggest ZendPdf as an alternative. Thanks
So one way to do this with the command line tool that foozy mentioned, but this leads to altering some one else's code and who wants that headache. You can can also do this with Composer using the autoload:classmap directive since it is a class even though it's not PSR-0.
Basically, you would place the TCPDF files somewhere convenient (vendor folder, lib folder, etc.) and then add the autoload directive to composer.json like so:
{
"autoload": {
"classmap": ["vendor/tcpdf"]
}
}
Assuming you placed the tcpdf folder in the vendor folder and that the TCPDF class is in the root of the tcpdf folder. Then you run php composer.phar update . Composer will then add that folder as a source location to the autoloader function it registers with the SPL autoloder.
Then where ever you want to use the TCPDF class you would do $pdf = new \TCPDF().
NOTE: I'm not 100% on the path being relative to the project root, composer.phar, or the vendor folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With