Laravel is a free, open-source PHP web application framework architected in a model–view–controller (MVC) pattern. phpGrid is a standalone CRUD component which includes all the necessary server and client side scripts. It does not need the Laravel packaging system to manage dependency.
- Laravel 7
- PHP >= 7.2 (required by Laravel)
- MCrypt PHP Extension or OpenSSL (required by Laravel)
- phpGrid Lite (free)
- Relational Database, e.g. MySQL
Laravel requires PHP version 7.2+ and MCrypt PHP Extension. Check your phpinfo file to verify the PHP. In this tutorial, we will be using the free version of phpGrid, phpGrid Lite.
Setting up Laravel:
The easiest way is to install Laravel is by using Composer. However, the Laravel installation procedure is outside the scope of this tutorial. Please visit http://laravel.com/docs/ for the Laravel installation process. For this demo, we will install the Laravel folder in the web server’s root directory.
phpGrid Folder Location in Laravel:
Now we need to setup the database connection and script path information in the file “conf.php”. Since phpGrid resides in “public” folder – Laravel’s front-end root directory – the value of phpGrid SERVER_ROOT should be “/phpGrid_Lite”. Don’t forget the slash at the beginning.
Learn more about SERVER_ROOT and other of phpGrid system variables here.
Finally, we need to create a view file in the Laravel “app/views” folder. Since phpGrid is located in Laravel’s “public” folder, we can reference the path to its conf.php file with Laravel’s public_path() helper function.
$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
Note that “orders” is a database table from the phpGrid sample database…. And that’s all there is to it! You have now integrated the power of phpGrid with the Laravel platform.