A simple script template that has some useful tools in PHP.
Simple, download this project, start to code your script inside the Scripts directory, and then modify the script.php
file.
The Template will help you with the configuration of your script, handle database connections and the queue schemas*
*not implemented yet.
In the script.php
you'll see a static call to a class method to get config, this will load the configuration file config.json
that is located inside Config directory (this file should follow the config.json.example pattern).
The config.json will be loaded in array format inside the global var $config
.
A PDO connection will be made calling the Connector
class of the connection you want, like in this example:
<?php
use Database\Postgres;
$pg = new Postgres\Connector("pglocal");
$conn = $pg->connect();
The pglocal
is the nabe of the connetion inside the config.json file.
Simple that way.