We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to use a '.class.php' library on my project

Hi guys, I want to use a library called PHP_XLSXWriter... to be more accurate I need to use a file called "xlsxwriter.class.php"

To use a library in my project I put the file on the library folder and when I'm going to use it in a controller, I just create a new instance.

By example: I have a library called simple_html_dom.php ... I have that file on my library folder, then on my code I use

'$objParser = new simple_html_dom();' And then I can use the library, no problem.

But with this "xlsxwriter.class.php" file I'm having some trouble. I can't use something like

"$var = new xlsxwriter.class"

because it gives me an error (because of the .class). I also can't use something like

include_once("xlsxwriter.class.php");

...again this gives me an error, the file doesn't recognize it.

Can you please point me in the right direction to use this file?? I'm sure it's something super simple, but I haven't been able to solve this. Thank you so so much for your help!

Hi!

You ussing mk-j/PHP_XLSXWriter - this lib?

In your case i prefer use composer and include composers's autoload.php in index.php of site. Composer will include xlsxwriter.class.php when you create instance XLSXWriter automaticly.

But nobody forbids include file in controller directly or in index.php of site.



4.3k

Sweet!! Thank you so much, I think I got it working now!

Hi!

You ussing mk-j/PHP_XLSXWriter - this lib?

In your case i prefer use composer and include composers's autoload.php in index.php of site. Composer will include xlsxwriter.class.php when you create instance XLSXWriter automaticly.

But nobody forbids include file in controller directly or in index.php of site.