Skip to main content

Posts

Laravel 5.4 Bootstrap row class for every 3 columns

Sometimes you need to show three or four columns in a row using Laravel 5.4 and blade template engine. Here I show how to do it using chunk function in Laravel blade. As the first step let's get products from the database and pass it to the blade view. And let's check our blade file. In the following example,  @ foreach  takes the  $ products array and chuck it. In this example, I split it by three. You can pass any number according to your specification. And you will see the inner @ foreach loop through  $ items. If you have any question please comment it and I will try to solve it.
Recent posts

Implementing binary search of an array in Java and Python

A binary search divides a range of ordered values into halves (two equal portions) and continues to split the array until the position of unknown value is found. It is an example of a "divide and conquer" algorithm. One of the common ways to use binary search is to find an unknown item in an array. It has the run-time complexity of O(log n). An array is a container object that holds a fixed number of values of a single type. In Java programming language the length of an array is established when the array is created. But in Javascript, neither the length of a JavaScript array nor the types of its elements are fixed. Python programming language considers arrays as lists that can contain mixed data types. Following paragraphs try to describe the binary search in details. Binary search works with only sorted collections. That is due to the binary search looks for a particular item by comparing the middle element of the array. If it matches the item we look for, the index o

Deploy Laravel 5.4 App on LEMP Stack (DigitalOcean Guide) Part - 4

This is the fourth part of the Deploy Laravel 5.4 App on LEMP Stack (DigitalOcean Guide) . In the last post, I have shown how to prepare the server for Laravel application deployment. And in this post, I'm going to show how to setup the local machine for production deployment. Make sure that your local Laravel directory is under git version control before you continue. If there is a .git folder in your Laravel folder that means Git is initialized. You can use git log command to check the commit logs. You can learn more about Git from the official website . Following command add new remote and set up our server as a push location. Substitute the red text with your domain name or IP address. git remote add production ssh://root@ 196.0.0.1 /var/repo/site.git You can run git remote command to view a list of existing remotes. You can execute the following command to push it to the server. git push production master It will prompt you to enter the password.The pr

Deploy Laravel 5.4 App on LEMP Stack (DigitalOcean Guide) Part - 3

This is a third part of the Deploy Laravel 5.4 App on LEMP Stack (DigitalOcean Guide) . In this post, I'm going to prepare the server for Laravel application deployment. Let's create a folder for our Laravel application. By default, NginX will look at the /var/www/ path to serve the files. In this folder let's create a folder called app. Open the following file to update the new path. Run the following command in your terminal. sudo nano /etc/nginx/sites-available/default Let's change the root line and add the public folder path. Change the following location section to add /index.php?$query_string; location / {                 # First attempt to serve request as file, then                 # as directory, then fall back to displaying a 404.                 try_files $uri $uri/ =404;         } Changed code section should look like this. Restart the server to changes to take effect. sudo service nginx restart Install Composer You can follow

Deploy Laravel 5.4 App on LEMP Stack (DigitalOcean Guide) Part - 2

This tutorial is the second part of the Deploy Laravel 5.4 App on LEMP Stack (DigitalOcean Guide) . Before I install LEMP stack, I am going to update the package installer. To do that run the following command in the terminal. It will grab the package list and update it. sudo apt-get update Install Nginx (Engine-X) Run the following command to install Nginx server. sudo apt-get install nginx   After the installation, you should be able to visit your IP address and it will show the Nginx default page. Install MySQL Run the following command to install MySQL on your server. sudo apt-get install mysql-server The above command will start the MySQL installation process. You will have to enter 'Y' and proceed. After few steps you will see the following screen. Enter root password and proceed. Default MySQL installation is famous for insecure. MySQL has a helper script to secure the MySQL installation. To run the script type the following command i

Deploy Laravel 5.4 App on LEMP Stack (DigitalOcean Guide) Part - 1

This blog post teaches you how to set up Laravel onto a virtual private server (VPS) using LEMP stack (DigitalOcean). LEMP is an acronym that stands for Linux, Nginx (Engine-X), MySQL and PHP. The reason I chose to use LEMP with Laravel is that it seems to be the preferred stack among the Laravel community. You can use LAMP stack as well, but when running smaller server instances like we are (with 512mb RAM), it has shown that Nginx performs better with limited resources. Why DigitalOcean? You can host it any VPS server that you wish. In this tutorial, I set up the server through SSH into VPS instance. But there are few reasons to choose DigitalOcean such as simple UI and minimalistic approach, SSD-based virtual machines, comprehensive documentation, affordable pricing and community & ecosystem Support. I have used DigitalOcean in production, and it works great. If you would like to sign up using Busy Programmer's Guide, you will get $10 to get started, absolutely free.

Mobile Backend As A Service (BaaS) platform for Android

Many mobile apps and games rely on a backend service for things that can’t be done solely on hosted device, such as sharing and processing data from multiple users, or storing large files. Backend as a service (BaaS) provides a centralised database and other features to manage user-generated data and application data. The developer can link applications to the backend service and backend service expose APIs to manage users, integrate push notification and analytics. BaaS is a recent development of cloud computing technology. Using backend services provide developers functionalities to manage users, data and to analyse real-time changes actively. Backend service should be able to handle the offline case gracefully and minimise battery drain. Back in the day developers had to develop custom backend platforms using server-side technologies. And developers had to scale up and down according to the user base and app usage. It was time-consuming in terms of resources and skills. Most mob