View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0001446||Main CAcert Website||[All Projects] General||public||2018-11-04 04:51||2018-11-11 18:36|
|Priority||normal||Severity||minor||Reproducibility||have not tried|
|Platform||Test CAcert Website||OS||N/A||OS Version||Test|
|Target Version||Fixed in Version|
|Summary||0001446: Add an autoloader as a step toward moving common code into classes|
|Description||Common code should be in classes. Classes can be delivered from a single class directory. An autoloader can make the class loading automatic. The autoloader can replace the multiple occurrences of require/require_once.|
The autoloader class could also replace the prepend defined in the Apache config file, removing a roadblock for people who cannot access their Apache settings.
|Additional Information||Create a directory outside the Web root named class or the same directory inside the Web root with a Web server config line to limit access to the class directory.|
Create a class named cacert in a class file named cacert.php in the class directory.
Add common code to every page to start with the loading of the cacert class.
In the constructor of cacert, register an autoloader function named autoloader.
Create the autoloader function to load classes from the class directory if they exist.
The class could also set directory paths and other similar values, such as the domain name, for use on every page.
|Tags||No tags attached.|
I modified index.php in my test to include a cacert.php.
cacert.php (36 bytes)
index.php (26,831 bytes)
The included cacert.php brings in a common cacert.php file from outside the Web root. There is a .ini file at the same level.
cacert.ini (221 bytes)
cacert-2.php (359 bytes)
The cacert.php file includes class/cacert.php
cacert-3.php (2,264 bytes)
||This structure was copied from other projects. You might like to work on the names, locations, and what is included from the .ini. I started a separate issue for the .ini and included the .ini here only as a simple way to load the .ini. The contents of the .ini would be better discussed in the other issue.|
|2018-11-04 04:firstname.lastname@example.org||New Issue|
|2018-11-04 04:email@example.com||Assigned To||=> jandd|
|2018-11-04 07:firstname.lastname@example.org||File Added: cacert.php|
|2018-11-04 07:email@example.com||File Added: index.php|
|2018-11-04 07:firstname.lastname@example.org||Note Added: 0005647|
|2018-11-04 07:email@example.com||File Added: cacert.ini|
|2018-11-04 07:firstname.lastname@example.org||File Added: cacert-2.php|
|2018-11-04 07:email@example.com||Note Added: 0005648|
|2018-11-04 07:firstname.lastname@example.org||File Added: cacert-3.php|
|2018-11-04 07:email@example.com||Note Added: 0005649|
|2018-11-04 07:firstname.lastname@example.org||Note Added: 0005650|
|2018-11-04 09:09||jandd||Project||Infrastructure => Main CAcert Website|
|2018-11-04 09:09||jandd||Category||general => General|
|2018-11-04 09:11||jandd||Assigned To||jandd =>|
|2018-11-09 21:59||Ted||Relationship added||child of 0001260|
|2018-11-09 22:00||Ted||Assigned To||=> email@example.com|
|2018-11-09 22:00||Ted||Status||new => needs work|