Skip to content

Configuration

Tim Erickson edited this page Sep 24, 2018 · 4 revisions

Configuration

How do you install a plugin on a new server?

Basically, move the plugin's folder to the server and you're almost done.

Establishing credentials: If the plugin uses an external database

(Or just needs php for some reason)

For access to php, you will need the URL of the php file. In our mythical foo plugin, that php file is probably foo.php in the very folder you are already in. As described in

For access to the mySQL database, you need a database handle, and in order to get that, you need credentials: the name of the database, a username, a password, and the URL of the mySQL server. The latter is simple: it's always localhost: we're running mySQL on the same server as we're running php. The rest are tougher. For security reasons, we don't want to put them, in cleartext, in a publicly-accessible file. So we store them above the level of the web server root.

For our plugin called foo, there might be a file called root/cred/fooCred.php that looks like this:

<?php
$credentials = array(
    "local" => array(        //  http://localhost:8888/foo/foo.php
        "dbname" => "foo",
        "host" => "localhost",
        "user" => "fooUser",
        "pass" => "foo42"
    ),
    "xyz" => array(         //  http://codap.xyz/projects/foo/foo.php
        "dbname" => "codapxyz_foo",
        "host" => "localhost",
        "user" => "codapxyz_foo",
        "pass" => "foo.wombat42"
    ),
    "eeps" => array(         //  https://www.eeps.com/foo/foo.php
        "dbname" => "denofinq_foo",
        "host" => "localhost",
        "user" => "denofinq_foo",
        "pass" => "foo42^&%"
    )
);
?>

As you can see, we store the credentials for a number of possible sites in this associative array. And the keys to the array ate the same as the whence variable.

Then, in the php itself, we do this (the beginning of a fictional foo.php):

include 'foo.establishCredentials.php';     //  tells us where the credentials are
header('Access-Control-Allow-Origin: *');
include '../common/TE_DBCommon.php';    // basic functions for connections and queries

$DBH = CODAP_MySQL_connect("localhost", $user, $pass, $dbname);   

The establishCredential.php code defines $user, $pass, and $dbname. We will need the output of the connect function, $DBH, for every interaction with the database.

Clone this wiki locally