The idea behind this project was to design a website data class to hold information about a website. The main reason for it was to provide an easy way to get database credentials for connecting to a local database. Rather than storing database credentials in the PHP code of each page that needs a connection or even storing the database credentials in code in an include page, this class has the ability to retrieve the credentials from seperate settings files. The database credentials are stored in JSON files. On creation of a website object these settings files are read and the credentials are stored in properties of the class. Then to access the credentials, public functions can be called to retrieve host/username/password/port/databasename. The class can currently read and store database credentials for both Mysql and Postgresql.
Care needs to be taken to secure the settings files. The default location for storing these files is a sub directory called 'Settings' inside the web root directory making it possible for them to be downloaded if the path is known. Some form of password protection or htaccess needs to be configured to protect the directory. It is possible to change the location of the settings files idealy outside the webroot. Server configuration permitting, the class can take an optional 'settingsDir' variable to change the location that it will read the settings files from. This variable needs to be an absolute directory path on the local server.