View Issue Details

IDProjectCategoryView StatusLast Update
0001446Main CAcert Website[All Projects] Generalpublic2018-11-11 18:36
Reporterpmoulding@cacert.orgAssigned Topmoulding@cacert.org 
PrioritynormalSeverityminorReproducibilityhave not tried
Status needs workResolutionopen 
PlatformTest CAcert WebsiteOSN/AOS VersionTest
Product Version 
Target VersionFixed in Version 
Summary0001446: Add an autoloader as a step toward moving common code into classes
DescriptionCommon 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 InformationCreate 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.
TagsNo tags attached.
Reviewed by
Test Instructions

Relationships

child of 0001260 needs workBenBE Make the source compatible with recent PHP versions 

Activities

pmoulding@cacert.org

2018-11-04 07:01

developer   ~0005647

I modified index.php in my test to include a cacert.php.

cacert.php (36 bytes)
index.php (26,831 bytes)

pmoulding@cacert.org

2018-11-04 07:03

developer   ~0005648

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)

pmoulding@cacert.org

2018-11-04 07:03

developer   ~0005649

The cacert.php file includes class/cacert.php

cacert-3.php (2,264 bytes)

pmoulding@cacert.org

2018-11-04 07:07

developer   ~0005650

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.

Issue History

Date Modified Username Field Change
2018-11-04 04:51 pmoulding@cacert.org New Issue
2018-11-04 04:51 pmoulding@cacert.org Assigned To => jandd
2018-11-04 07:01 pmoulding@cacert.org File Added: cacert.php
2018-11-04 07:01 pmoulding@cacert.org File Added: index.php
2018-11-04 07:01 pmoulding@cacert.org Note Added: 0005647
2018-11-04 07:03 pmoulding@cacert.org File Added: cacert.ini
2018-11-04 07:03 pmoulding@cacert.org File Added: cacert-2.php
2018-11-04 07:03 pmoulding@cacert.org Note Added: 0005648
2018-11-04 07:03 pmoulding@cacert.org File Added: cacert-3.php
2018-11-04 07:03 pmoulding@cacert.org Note Added: 0005649
2018-11-04 07:07 pmoulding@cacert.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 => pmoulding@cacert.org
2018-11-09 22:00 Ted Status new => needs work