Instances and servers
Platform4PHP is intended as a multi-instance platform, where each instance is a copy of the application with its own database and own file storage. Platform4PHP supports multiple servers naturally, but works perfectly on a single server.
In order to coordinate all servers in a cluster, a global database is needed containing information about the individual instances, servers and we also keep track of scheduled jobs here.
Our tutorial People HR app is an app designed to be used by businesses to keep track of their employees. Each business want their own solution, with their own employees and nothing to do with other businesses, so therefore it is natural for us, to have each business within their own instance.
The server system works totally transparent with the instances, and will default try to balance the same number of instances on each server.
The server we installed Platform4PHP on, is already included in the server registry.
To begin our new app, we subclass the Platform4PHP Instance class in our own namespace called People. The Platform4PHP class loader will expect the class file to be placed at /People/Instance/instance.php located from the webserver root.
- Instance.php
<?php namespace People; Class Instance extends \Platform\Instance { public function initializeDatabase() { parent::initializeDatabase(); } }
Even though the class is an exact copy of its parent class, we'll soon get back to the initializeDatabase
function, so that's why I've included it.
That's it.