Hello, everyone.
What solution would you recommend for including files in a PHP project?
- There aren't manual calls of require/include functions - everything loads through autoload functions
- Package importing, when needed.
Here is the package importing API:
import('util.html.HTMLParser');
import('template.arras.*');
In this function declaration you can explode the string with dots (package hierarchy delimeter), looping through files in particular package (folder) to include just one of them or all of them if the asterisk symbol is found at the end of the string, e.g. ('template.arras.*').
One of the benefits I can see in package importing method, is that it can force you to use better object decomposition and class grouping.
One of the drawbacks I can see in autoload method - is that autoload function can become very big and not very obvious/readable.
What do you think about it?
- What benefits/drawbacks can you name in each of this methods?
- How can I find the best solution for the project?
- How can I know if there will be any performance problems if package management is used?