Page 1 of 1

/ext or /apps folder for a PHP Class

Posted: Tue Apr 27, 2021 11:07 am
by loop
Hi
I'm wondering where to put a php class i need (FPDF, to create PDF, which i will need in admin and catalog).
whats the differece from the /ext folder and /includes/apps ?
thank you !

Re: /ext or /apps folder for a PHP Class

Posted: Tue Apr 27, 2021 3:42 pm
by ecartz
ext/ is for pages that you need to access from applications that aren't Phoenix. You probably do not want to put a class file there. In general, ext/ is not where you put something that you would include or require from PHP. It is where you put things that are loaded directly via URL.

includes/apps/ is for things that you do not want to autoload through Phoenix, perhaps because they have their own autoloader or naming scheme. You could include a class file from there. If you do, you will have to load it yourself.

If you just want to add a class for use in admin, try admin/includes/classes/override/

If you want a class for catalog (which will also work in admin), try includes/system/override/

Note that if you put it in an override directory to be autoloaded, it will have to be named like a Phoenix class:

Fpdf or fpdf in fpdf.php
FPDF in f_p_d_f.php

I.e. any capital letter in the class name after the first letter must be lower case in the file name and preceded by an underscore. This is to make class names like ShoppingCart look in files like shopping_cart.php

Re: /ext or /apps folder for a PHP Class

Posted: Tue Apr 27, 2021 5:26 pm
by loop
Thank you!
but only to know the reason, if i need a php class ONLY in admin, why i cant put it in /admin/includes/classes ?
As it's a new file, i would not change a core class (why should i use override?)
thank you!

Re: /ext or /apps folder for a PHP Class

Posted: Tue Apr 27, 2021 5:29 pm
by ecartz
You could. But then if core added a file with the same name, it would overwrite your file.

Re: /ext or /apps folder for a PHP Class

Posted: Tue Apr 27, 2021 5:30 pm
by loop
okay, good point...