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 !
/ext or /apps folder for a PHP Class
-
- Lead Developer
- Posts: 2656
- Joined: Tue Nov 05, 2019 6:02 pm
- Has thanked: 4 times
- Been thanked: 182 times
Re: /ext or /apps folder for a PHP Class
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
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
-
- VIP Member
- Posts: 230
- Joined: Thu Mar 25, 2021 12:26 pm
- Has thanked: 7 times
- Been thanked: 3 times
Re: /ext or /apps folder for a PHP Class
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!
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!