Laravel Framework Automated Installation for Developing PHP Applications

By | April 4, 2019

Laravel is an open source PHP Framework for developing web applications using an architectural template based on Symfony Model-View-Controller (MVC). It is highly popular among developers due to its rapid development capabilities.

In Laravel, the framework code is separated from the developer’s one and each component is easily extensible. It supports working with various databases, sending notifications in various ways: mail, Slack, etc. and websockets technology for creating real interactive applications.

lavarel framework

Laravel Framework Installation

Let’s get through the installation process.

1. Enter the Jelastic dashboard, find Laravel framework in the Marketplace and press Install.

lavarel in marketplace

Alternatively, you can import the Laravel PHP framework manifest.

2. In the opened dialog, specify the Name of Environment and choose the preferred Region. Click on Install.

Laravel Framework Installation Wizard

3. Wait a few minutes till installation is completed. Open the welcome page of a default Laravel project from the successful installation message by pressing Open in Browser.

Laravel Successfully Installed

Welcome page contains the first essential links for getting started with the framework.

Laravel Default Project Welcome Page

Creating Laravel New Project

The new project is the independent clone of the default one that was created while the framework installation.
Let’s create a Laravel new project with database CRUD operations example.

1. Add a database node to the environment.
To do this press Change Environment Topology and add a database node, for example, MySQL.

Note: if you decide to use MySQL/MariaDB database cluster with ProxySQL in front of it, there must be chosen the following database version:

  • MariaDB 10.2
  • MySQL 5.7

Change Laravel Environment Topology

Add necessary resources in Vertical Scaling per Node section and press Apply.

Adding a Database to Laravel

2. Once the database node is added to the environment the topology is changed.

Laravel Environment Topology

The database access credentials can be found in the respective email.

3. In order to cut time, you can use a simple script newdb-project.sh from our Laravel repository that automates the following operations:

  • creates a new Laravel project
  • creates the database and table to store the URL links
  • fills out the table with fake data
  • creates data insert form
  • adds necessary routes to web.php file
  • describes request treatment logic to work with the database and tables in Controller.php file
  • displays data from the database at a new project welcome page
  • adds an action link Replace links to the welcome page

The script comes with brief comments in it and can be found in the framework root directory ~/webroot/ROOT after package installation or downloaded from GitHub by link.

4. To create a new Laravel project connected to the database, open the Web SSH client and issue:

~ $ cd webroot/ROOT/
~ /webroot/ROOT $ ./newdb-project.sh root

Where the script arguments are project name and database credentials (see respective email):

– a new project name, the first letter must be in upper case (e.g. Myproject)

– database entry point hostname (e.g. node201708.laravel.jelastic.cloud).
In case of database cluster (master-master, multi-primary group or galera cluster replication topologies), to ensure high availability mode via DNS Round-Robin distribution for the domain names with multiple IP records, it is possible to use layer names as entry point hostname e.g.:

  • sqldb.laravel.jelastic.cloud if application refers to database nodes layer
  • proxy.laravel.jelastic.cloud if there is a ProxySQL load balancer layer in front of database cluster.

After each request is processed, the order of addresses will be cyclically shifted, moving first IP down, which results in even workload distribution among all of the layer nodes.

root – database username

<password> – database password

Establish Database Connection from Laravel Project

5. Once script execution is finished, open the link of this type http://<domain>/<Myproject>/public/
In our case, it is http://laravel.jelastic.cloud/Myproject/public/

Laravel Framework Welcome Page Composed from Database.

As it is shown on the picture the Laravel project related links were changed with the fake data links. Open the phpMyAdmin panel specified in email to see these data in the database.

phpMyAdmin access to Laravel Database

Now, we can change the data in the table, click on Replace links as on the welcome page above.

Change the data in the displayed form that is generated by the insertForm.blade.php layout template file or just press the Replace button to replace fake information with custom.

Read Data from Laravel Database

Once data is applied, it is written to the database and displayed at Myproject welcome web page.

Jelastic Useful links in Laravel

The actual process takes less than 1 minute (see below).

Laravel New Database Project How To

CI/CD Development Pipeline

In order to start coding, you should establish a CI/CD pipeline from your local computer to Laravel application through Git server with the help of Jelastic Deploy from Git/SVN functionality.

To describe an algorithm, we use Linux OS on local computer.

1. Create a new empty repository at GitHub and name it for example as MyprojectCICD.

2. Clone new repository to your local computer with command:

~$ git clone https://github.com/user/MyprojectCICD

3. Copy the content of Laravel Myproject directory to MyprojectCICD repository:

  • Log in to application server via SSH and issue commands to create a tar archive:

~$ cd ~/webroot/ROOT/Myproject

~/webroot/ROOT/Myproject$ tar -cf myproject.tar .

Compress a Laravel Project

Download Laravel Project to Establish CI/CD

  • Extract files from archive to the directory of local repository:

~/Downloads $ tar -xf myproject.tar -C /home/user/MyprojectCICD

4. Push repository changes to GitHub:

~/Downloads $ cd /home/user/MyprojectCICD

~/MyprojectCICD $ git add -f .

~/MyprojectCICD $ git commit -am “All files of Myproject added to repository”

~/MyprojectCICD $ git push

5. Click on Deploy from Git/SVN to configure deployment as it is described in our documentation.

Jelastic Deployment to Establish CI/CD for Laravel
Deploy Laravel Project via Jelastic Deployment Manager

Once Deploy button is pressed it clears ROOT context directory and puts MyprojectCICD repository content into it. Thus local Laravel PHP project is synchronized with project in the cloud and can be accessed by new ROOT context link, e.g. http://laravel.jelastic.cloud/public. Change your code locally via any text editor or IDE, commit changes, push them to GitHub and Jelastic will do the rest, just refresh the project webpage.

Now you know all the basics how to install Laravel framework and start own PHP project in a few minutes using Jelastic PaaS. Try it out at one of the globally-available Jelastic providers.

Subscribe to get the latest updates