Configuring TCPDF for use on local server with MAMP

Wednesday, November 4, 2015

I wish to use TCPDF so have downloaded the code and am having trouble using it.



I work on Mac locally using MAMP.



My project is stored in:




/Applications/MAMP/htdocs/my-project-title




I place the whole tcpdf folder in my project so it's location is:




/Applications/MAMP/htdocs/my-project-title/tcpdf




I found a file tcpdf_include.php in the examples directory so I pulled it out and placed it also in the tcpdf folder:




/Applications/MAMP/htdocs/my-project-title/tcpdf/tcpdf_include.php




So I wasn't sure if this was right but it seemed so. I then referenced tcpdf_include.php in my script: require_once('../tcpdf/tcpdf_include.php'); and it found the file all good.



Now I was confused as to how exactly this was working. I ran an example and got nothing and error log states:




[04-Nov-2015 16:27:36 Europe/Berlin] PHP Fatal error: Class 'TCPDF' not found in /Applications/MAMP/htdocs/my-project-title/scripts/myscript.php on line 15




... so it seems like it's just not running the script. I went to the config file to attempt to edit some stuff there.



I changed the following in the config file:



define ('K_PATH_MAIN',  '/MAMP/htdocs/my-project-title/tcpdf/');
define ('K_PATH_URL', 'http://localhost:8888/my-project-title/tcpdf/');


These are now inline with how my project is set up. But I'm still getting the above error when I try to run the script.



What am I missing are there any examples of how to properly configure TCPDF?

0 comments:

Post a Comment