Math library architecture
My math hobby has continued to peak my interest for the last few months. Such explorations have motivated me to think about ways in which my code base might be organized to anticipate future growth.
I've provisionally settled on the directory structure in Listing 5:Listing 5. A growth-friendly directory structure
Future work on multiple regression, for example, would involve extending this library to include a matrix directory to house PHP code for performing matrix operations (a requirement for more advanced forms of regression analysis). I would also create an mr directory to house PHP code that implements the input, logic, and output methods for multiple regression analysis.
Note that this directory structure contains a temp directory. Permissions on this directory must be set so that the explore.php script can write output plots to this directory. Keep this in mind when you try to install the phpmath_002.tar.gz source code. Also, read the instructions for installing JpGraph on the JpGraph project Web site (see the Resources).
On a final note, it is possible to move all software classes to a document root other than the Web root if you:
- Let a global
PHP_MATHvariable have access to a non-Web root location, and
- Make sure you prefix this defined constant to all required or included file paths.
In the future, setting the
PHP_MATH variable might be done through a config file for the PHP math library as a whole.