Demo App

To get you started with the DataTables libraries and Editor on your own server (or development machine), we provide a demo application that includes all of the Editor examples on this site, including their server-side scripts and the SQL for the backing database.

The demo app can be downloaded and then installed on your server or run locally. This guide will walk you through that process.

Download

To download the Editor PHP demo app, if you haven't already, open the Editor download page and download the PHP package.

When the download completes, unzip the Editor-PHP-3.0.0-beta.1, ready for editing, running or uploading.

Examples SQL

The next step is to load your database with the tables and data required for the Editor demos. The DataTables PHP libraries work with a number of different databases, each of which requires its own SQL. The following links contain the SQL needed for each of the supported databases:

Select the appropriate file for your database and then run the SQL contained within on your database access portal (SQL Server Management Studio, CLI, phpMyAdmin or pgAdmin3 for example). The demo SQL will create new tables and enter data into them. Note that they will overwrite any conflicting table names - installing the demo into a new database is recommended and also, as is good practice, ensure that you have backed up your database.

Database connection

Now that the database is primed with data and tables, we need to instruct the examples how to make a connection to the database so it can perform CRUD actions. For this the only file you need to edit is lib/config.php in the Editor directory.

Edit this file in your preferred text editor by simply filling in the parameters of the $sql_details array - this array provides the information that the DataTables libraries need to make a connection to your database.

The config.php file will look like this:

<?php if (!defined('DATATABLES')) exit(); // Ensure being used in DataTables env.

// Enable error reporting for debugging (remove for production)
error_reporting(E_ALL);
ini_set('display_errors', '1');
 
 
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Database user / pass
 */
$sql_details = array(
    "type" => "",    // Database type: "Mysql", "Postgres", "Sqlserver", "Sqlite"
    "user" => "",    // User name
    "pass" => "",    // Password
    "host" => "",    // Database server
    "port" => "",    // Database port (can be left empty for default)
    "db"   => "",    // Database name
    "dsn"  => "",    // PHP DSN extra information. Set as `charset=utf8mb4` if you are using MySQL
    "pdo"  => null   // Existing PDO connection. Use with `type` and no other parameters.
);

Note that on lines 3-5 we enable error reporting. This can be very useful for debugging problems when getting started with Editor, but you may wish to remove these two lines before deploying your web-site.

Web-server

We are now ready to run the demo application and view the examples in your browser. There are two options here:

  • Run the examples using PHP's built in dev server
  • Upload to a PHP server

Dev server

To run the examples locally for quick and easy testing, you can make use of PHP's built in web server. To do this, on your command line terminal in the demo app directory simply run:

php -S localhost:8080

You will then be able to access the examples at http://localhost:8080/examples.

PHP server

Alternatively, if you have a PHP server you'd like to run the files on, simply upload the files to your web-server. The Editor PHP demo files will run on any web-server capable of running PHP 7 or newer. Then to view the examples load your your web-site in your browser: http://myWebSite.com/Editor-PHP-3.0.0-beta.1/examples/

Edit these files and look around at how things are done to get an idea of how you can implement your own Editor use cases on your own sites / app!