Web-based install
This is the easiest method for installing phpGrid on your web server. It is the recommended for installing Lite version. Simply extract phpGrid zip file into the web folder, and run install.php from the browser. For example http://localhost/phpGrid_Lite/install.php.
For demo, the only database type supported is MySql. Enter database hostname, username and password in the form, and choose wether to create a new database or not, then hit Install button.
Upon successful demo install, you will be redirect to the demo explorer where one can check out list of live examples and their source code.
Manual Install
If you choose to manual install, first and foremost, download the phpGrid and extract the zip file somewhere on your web server.
Install Sample Database
You can find the sample database script for our demo in examples/SampleDB folder.
Configuration
Before you begin coding using phpGrid, you must specify database information in conf.php. conf.php is our phpGrid configuration file in which we specify database connection parameters and path to the phpGrid.
Starting phpGrid version 6, The constant names prefixed with “PHPGRID_” to avoid potential naming collision. Please note that in PHP the method name and parameters are case sensitive.
conf.php for phpGrid version 6 and above (find phpGrid version #):
1 2 3 4 5 6 | define('PHPGRID_DB_HOSTNAME','hostname'); // database host name or TNS name (Oracle only) define('PHPGRID_DB_USERNAME', 'username'); // database user name define('PHPGRID_DB_PASSWORD', 'password'); // database password define('PHPGRID_DB_NAME', 'sampledb'); // database name define('PHPGRID_DB_TYPE', 'mysql'); // database type define('PHPGRID_DB_CHARSET','utf8mb4'); // OPTIONAL. Leave blank to use the default charset |
conf.php for phpGrid version 4, 5, 5.x (find phpGrid version #):
1 2 3 4 5 6 | define('DB_HOSTNAME','hostname'); // database host name or TNS name (Oracle only) define('DB_USERNAME', 'username'); // database user name define('DB_PASSWORD', 'password'); // database password define('DB_NAME', 'sampledb'); // database name define('DB_TYPE', 'mysql'); // database type define('DB_CHARSET','utf8mb4'); // OPTIONAL. Leave blank to use the default charset |
For PHPGRID_DB_CHARSET, before MySQL 5.5.3 or earlier, use utf8. Use utf8mb4 for later version. Leave it blank if you are not sure to use default character set.
Hint:
If you need Emoji, then you need ‘utf8mb4’ character set 😁
If you use Apache alias directive or IIS virtual directory, you need to also set SERVER_ROOT value.
1 | require_once("phpGrid/conf.php"); // relative path to conf.php without leading slash |
– or –
1 | require_once(realpath($_SERVER["DOCUMENT_ROOT"]) ."/phpGrid/conf.php"); // absolute path to conf.php |
Database Type
phpGrid supports wide range of database types. Simply define PHPGRID_DB_TYPE parameter value to your own database type. It can be one of the following strings. The default database type for phpGrid is “mysql”. PHPGRID_DB_TYPE string is case sensitive.
PHPGRID_DB_TYPE | Description |
---|---|
mysql | MySQL (default, using the new MySQLi driver) |
mysql_dsn | MySQL (similar to above but using DSN) |
odbc_mssql | SQL Server (*nix Only) |
odbc_mssql_native / sqlsrv | SQL Server Windows native (Download PHP SQL Server Driver) |
oci805 | Oracle (Got TNS?) |
sqlite | SQLite |
postgres | PostGreSql |
access | Microsoft Access |
pdo_odbc_db2 | DB2 (PDO) |
db2 | DB2 (Requires IBM_DB2 extension in IBM i environment) |
db2-dsnless | DB2 DSN-less connection |
informix | Informix |
informix72 | Alternative Informix Driver |
ibase | Firebird/InterBase |
odbc | Generic ODBC |
A full list of supported databases and naming convention are available in ADOdb website. Not required but we encourage users to visit ADOdb website. It helps you understand how phpGrid utilizes it under the hood.
phpGrid now supports local array data source without using a database.
PHP Grid Oracle 9, 10g, 11g, 12c
When using PHP datagrid for Oracle database with TNS (Transparent Network Substrate), replace the database host name with the TNS Name in conf.php e.g.
1 |
IBM i for DB2
DB2 requires ibm_db2 extension and one additional configuration setting – PHPGRID_DB_OPTIONS. Learn more about phpGrid DB2 support.
1 |
Microsoft SQL Server
SQL Sever needs to use Mixed Authentication (SQL Server and Windows Authentication) mode to include SQL Server Authentication because the default authentication is Window authentication.
Below is a common error when SQL Server authentication is not enabled
1 | Fatal error: Uncaught TypeError: sqlsrv_query(): Argument #1 ($conn) must be of resource, bool given |
Following SQL Server official document to change SQL Server authentication mode: Change SQL server authentication mode. We recommend SMSS (SQL Server Management Studio) if you are more conformable with a graphic user interface.
Lastly be sure to restart SQL Server afterwards.
Firebird
Firebird is supported via “ibase” and “odbc”. Newer Firebird PHP driver is not yet supported due to ADOdb still has it under development. KB: Firebird Install & Setup on Windows, and Firebird Install & Setup on MacOS
SERVER_ROOT
In conf.php, SERVER_ROOT is the value tells your script where to find phpGrid library on web server. By default, it sets URL absolute directory path to phpGrid library automatically with the following script, so you don’t have to.
1 | define('SERVER_ROOT', str_replace(str_replace('\\', '/', realpath($_SERVER['DOCUMENT_ROOT'])),'', str_replace('\\', '/',dirname(__FILE__)))); |
When to set SERVER_ROOT value manually
Whenever you use Apache alias directive or IIS virtual directory, you need to set SERVER_ROOT value manually.
SERVER_ROOT value is the URL to the phpGrid library folder subtracts the host name. For instance, if the URL to get to the phpGrid is http://www.yoursite.com/phpGrid, or http://localhost/phpGrid, the SERVER_ROOT should be “/phpGrid” – with leading slash.
1 |
Another example, if the URL to phpGrid is http://www.yoursite.com/admin/phpGrid, or http://localhost/admin/phpGrid, the SERVER_ROOT should be “/admin/phpGrid” – with leading slash,
1 |
Composer Install
Starting version 7.5.3, phpGrid incorporates Composer as the package manager to manage popular dependencies such as ADOdb, PHPSQLParser, etc. The goals to gradually migrate to Composer for all dependencies. It ensures the dependencies can be updated by end users directly without going through phpGrid’s support, and also importantly without bloating the downloads.
Simply run the following install command in phpGrid root folder
1 | composer install |
Addition Resources on Composer
- Read our recent post PHP Composer to Autoload a Third Party Library to learn more about using Composer.
- phpGrid Common composer install issues
- Composer official website: https://getcomposer.org