Blogging Fusion Blog Directory the #1 blog directory and oldest directory online.

My Programming Tutorials

Home My Programming Tutorials

My Programming Tutorials

Rated: 2.57 / 5 | 2,816 listing views My Programming Tutorials Blogging Fusion Blog Directory

India

 

General Audience

  • Paritosh Pandey
  • November 21, 2017 09:13:25 PM
SHARE THIS PAGE ON:

A Little About Us

My Programming Tutorials is one stop solution for passionate programmers which provides various tips and tricks on mobile app and web development and google apis.

Listing Details

Listing Statistics

Add ReviewMe Button

Review My Programming Tutorials at Blogging Fusion Blog Directory

Add SEO Score Button

My Blogging Fusion Score

Google Adsense™ Share Program

Alexa Web Ranking: 372,978

Alexa Ranking - My Programming Tutorials

Example Ad for My Programming Tutorials

This what your My Programming Tutorials Blog Ad will look like to visitors! Of course you will want to use keywords and ad targeting to get the most out of your ad campaign! So purchase an ad space today before there all gone!

https://www.bloggingfusion.com

.

notice: Total Ad Spaces Available: (2) ad spaces remaining of (2)

Advertise Here?

  • Blog specific ad placement
  • Customize the title link
  • Place a detailed description
  • It appears here within the content
  • Approved within 24 hours!
  • 100% Satisfaction
  • Or 3 months absolutely free;
  • No questions asked!

Subscribe to My Programming Tutorials

What is SCRUM? The 5-letter Framework Explained!

In the world of information technology, time is everything. Most of the fields in science have centuries to develop their theories and concepts. IT, on the other hand, is relatively new, as the internet was just introduced to the internet late into the previous century. There have been some echoes in the minds of the… Read More » The post What is SCRUM? The 5-letter Framework Explained! appeared first on My Programming...

what-is-scrum

In the world of information technology, time is everything. Most of the fields in science have centuries to develop their theories and concepts. IT, on the other hand, is relatively new, as the internet was just introduced to the internet late into the previous century. There have been some echoes in the minds of the greatest scientists, but it is only in the 21st century that maximized the internet’s potential. Now, the interest in this particular field may have reached its peak, but people are still learning more from it.

One of the most lucrative parts of information technology is software development. There are so many avenues that this can take you. Mobile applications are also considered as software ones, and this is the focus of most industries these days. Smartphone use has increased dramatically over the past years, but other devices are keeping up. All of them need some sort of software to function. Whether it is the operating system to the application themselves, it is a top priority when it comes to any device.

This is why most software companies would want to release their products as fast as they can. The world of the internet and its consumers is a fickle one. Trends come and go, and that can be applied to the software being used. People want better devices and companies then would want faster roll-outs as well. However, developing an application can take months or even years to prepare. Once it does reach completion, the general public may have moved on already. You also need to know the difference between a trend and fad as this article says.

Developers are now trying to use all the ways and means to make production faster. One of which is following a procedure or guide that has been used for the last 20 years. This is known as SCRUM, a set of principles and values that has been taken from the Agile work methodology. In general, scrum gives the idea that customer’s needs are volatile; they can change faster than one might think. As a developer, you need to keep track of these changes and follow them to appease these kinds of demands.

SCRUM in Detail

scrum-in-detail

If you are into rugby, then you might be familiar with this term. It can be thought of as a reset mode for all the players. If they want to have the ball, all of the players will have to huddle together. Even if you are in different teams, you need to be together because you have one goal: to get the ball. In development teams, you are not working against each other to get the “ball” though. Instead, you would be working together to achieve something bigger. How does SCRUM make a difference?

Before, most software developers would follow a format. It follows a long process from planning to production and maintenance. This is also known as the waterfall method, since it goes “lower” the more advanced the process becomes. It has been quite effective since it has been used for a long time even in industries not concerned with information technology. However, as we moved to the modern era, it has been found to be not enough anymore.

One of the main problems of the waterfall method is the time consumption. Most of the projects done before can take months of planning before anyone can even begin working to it. Thus, once the project is already finished, the people who want it have already moved on. As mentioned before, trends can be born and die without notice or flair. If you get behind, then it would be over for you and your company.

With SCRUM, you may have a higher workload but it will be finished in a shorter time. This method divides the tasks amongst its members, with each task having its own process from planning to execution. Each of these processes is called a sprint, in which its products can be considered as your milestone for your ultimate goal. With each sprint, there should be a workable or potential product. This way, the team would not be trapped in a cycle of planning and there is visible progress.

There are three key members though: the product owner, scrum master and the team. It is the product owner’s responsibility to relay what they want. They can be the company owner or even the customers. The scrum master is the glue that would bind the team together. It is their duty to work with the team and make sure that they do not stray from the goal. Then, the team does all the work like testing and reviewing the product. As there is a distinction between them, the process becomes more streamlined and you do not have to waste a lot of time.

Applying the Process

If you want to apply this method to your team, you can find a lot of resources online like this one. However, if you want to have an in-depth knowledge, you can try hiring an expert like the ones in agile.coach website. They can certainly help you with organizing your SCRUMs, sprints and even forming the teams. Also, they can be the guide to help you use this method effectively. You can even apply this to other industries so make sure to learn about it in advance.

SCRUM is not the only methodology that you can apply to your company. However, there have been a lot of companies who had seen success with this model. It might take some time, but it is so much faster compared to its contemporaries.

The post What is SCRUM? The 5-letter Framework Explained! appeared first on My Programming Tutorials.


16 Best Tools for Programmers to increase productivity

In this article, we are going to know about some best tools for programmers, which will definitely prove to enhance their productivity. This piece of content is specially written for new programmers and web developers. Because they literally just don’t know that some magical tools available out there to reduce their load. Hey! you are… Read More » The post 16 Best Tools for Programmers to increase productivity appeared first on My Programming...

In this article, we are going to know about some best tools for programmers, which will definitely prove to enhance their productivity.

This piece of content is specially written for new programmers and web developers.

Because they literally just don’t know that some magical tools available out there to reduce their load.

Hey! you are not alone newbie fellows, we have all gone through this phase.

Based on my experience, I have listed down some programmers tools, which could be useful in web development, mobile app development, API development & security, etc.

Here is the list of best tools for programmers

1. https://css.github.io/csso/csso.html

CSSO (CSS Optimizer) is a CSS minifier. Actually, it is a lot more than a minifier. It minifies the CSS obviously! but it optimizes them as well.

The important feature that makes it the best is, it restructures the CSS, so it becomes as short as possible.

 

2. https://apetools.webprofusion.com/

If you are into mobile app development, literally !this tool is not less than a boon for you.

It automatically creates all the required sizes of Icons and Splash screens for your app instantly for all major platforms.

 

3. https://www.sassmeister.com/

Have you ever felt helpless while surfing through codepen.io after finding a module that uses saas? if yes! this tool is for you.

It converts Sass into CSS.

 

4. https://incarnate.github.io/curl-to-php/

It is so tough to convert a CURL commands into PHP. This tool lets you convert any CURL commands into complete PHP codes automatically.

 

5. https://www.diffchecker.com/

Diffchecker, as the name suggests, is a diff tool to compare text differences between two text files.

It is very useful in the diagnosis and debugging process.

 

6. https://pidoco.com/en

Pidoco is a wireframing tool to create fully interactive UX prototypes with drag and drop functionality.

I personally use this tool to create the project’s wireframes.

 

7. https://cssminifier.com/

This tool lets you minify your CSS codes.

After completing a web development project it becomes necessary to optimize its CSS codes so that it could load faster. This is where this tool comes in.

It only minifies the CSS codes and manages them in a single line. It doesn’t optimize them as CSSO does.

I personally recommend you to use CSSO.

 

8. https://www.freeformatter.com/html-formatter.html

HTML codes are always supposed to be written in a formatted way. This way it becomes readable and can be diagnosed by anyone easily.

If you are dealing with pretty heavy unformatted HTML codes then this HTML formatter tool will definitely help you a lot.

 

9. https://unminify.com/

This tool could help you with the maintenance work for your finished projects. It will let you un-minify the minified CSS & Js codes.

Un-minified codes are always easy to read and understand. So it becomes necessary to unminify all the minified codes while performing maintenance work.

 

10. https://www.flaticon.com/

Flaticon is the largest database for free icons available in PNG, SVG, EPS, PSD, and BASE 64 formats.

They have a huge number of free Icons available. They also allow you to customize icons after quick registration.

 

11. https://flatuicolors.com/palette/defo

Flatuicolors is a website where you can find a huge number of professional color combinations that you can use it in your website designs or in mobile UI designs.

 

12. https://jsonlint.com/

This tool is used to validate & reformat the JSON codes.

As you all know JSON is a regular string containing data. But it is harder to read unformatted JSON.

If you are an API developer or dealing with JSON strings, this tool will definitely help you to understand them.

 

13. https://www.base64decode.org/

This tool will let you reverse or decode back to the original data which is encoded using the base64 method.

While performing the debug process this tool will help you a lot.

 

14. https://www.canva.com/

If you are a website designer or a Blogger, this tool is for you. It will help you with creating a logo and creatives.

Although with Canva you can create videos, presentations, resume, visiting card and much more.

 

15. https://icons8.com/preloaders/

Preloaders provide cool animated loaders. This site is the best on the internet when it comes to animated loaders.

You can easily customize your loaders with the help of the generator tool they provide. After you have done with your customizations you can download it in GIF, APNG & SVG formats.

You can use it on websites as well as in mobile applications.

 

16. http://tools.dynamicdrive.com/imageoptimizer/

I personally use this online image optimization tool, using this tool you can optimize jpg, jpeg, png & gif types of images.

The best part of this tool is that it generates multiple optimized results so that you can choose the desired optimization level you want.

 

Final words

It is always better to work smarter rather than harder. The very precious thing in today’s busy world is time, so try to save it as much as possible.

happy coding!

The post 16 Best Tools for Programmers to increase productivity appeared first on My Programming Tutorials.


Learning and coding with CodeLabs

What is CodeLabs? Codelabs is an online platform for learning and practicing programming. It provides a guided tutorial on how a programming language works and allows the user to learn a new programming language quickly. The user can execute their programs in the programming lab provided on the browser. The various programming languages available on… Read More » The post Learning and coding with CodeLabs appeared first on My Programming...

What is CodeLabs?

Codelabs is an online platform for learning and practicing programming. It provides a guided tutorial on how a programming language works and allows the user to learn a new programming language quickly. The user can execute their programs in the programming lab provided on the browser.

The various programming languages available on CodeLabs are :

  • PHP
  • Ruby
  • Python
  • JavaScript
  • Angular
  • Java
  • MySQL
  • React

PHP :

PHP is a server-side scripting language which is used for developing software applications. Its components are free to use as it is an open source programming language. PHP is compatible with all operating systems i.e. it is platform independent. It is the most preferred language for CMS development, as it can be fully customized to match customer needs.

Advantages of PHP :

  • Easy
  • Reliable
  • Fast
  • Dynamic
  • Secure

Applications of PHP:

  • File Handling
  • Parsing XML documents
  • Executing Shell Commands
  • Encryption using MD5 and SHA1 hashing algorithms

Ruby :

Ruby is an object-oriented general-purpose programming language. It is one of the commonly used programming languages in the world. It was originally designed with the goal of making programming fun. Its syntax is easy to read, write and understand. Just like PHP, Ruby is also a platform independent programming language.

Advantages of Ruby :

  • Cost-Effective
  • Productive
  • Consistent
  • Refined

Applications of Ruby :

  • Internet applications and Intranet applications
  • Form Processing
  • Web Applications
  • Writing CGI Scripts

Python :

Python is an interpreter, high-level programming language. It emphasizes code readability and has a syntax similar to the English language. It allows the user to write programs having greater functionality with fewer lines of code. Python can be used for developing desktop GUI applications, websites, and web applications.

Advantages of Python :

  • Extensible
  • Embeddable
  • Portable
  • Robust Standard Library
  • User-Friendly

Applications of Python :

  • Desktop applications based on GUI
  • Scientific and numeric applications
  • Web frameworks
  • Software Development
  • Education

JavaScript :

JavaScript is a lightweight programming language which is designed for creating network-centric applications. It is an open and cross-platform programming language. It is very easy to implement as it is integrated with HTML. It has object-oriented capabilities.

Advantages of JavaScript :

  • Dynamic
  • Weakly typed
  • Simple
  • Versatile
  • Increased interactivity

Applications of JavaScript :

  • Mobile Applications
  • Graphics
  • Client-side programming
  • Validating user input
  • Displaying pop up and dialogue boxes

Angular :

Angular is a TypeScript-based front-end web application framework. The very first version of Angular is known as AngularJS. It is easy to learn and is mainly used for building single page applications (SPAs).

Advantages of Angular :

  • Consistent
  • Productive
  • Maintainable
  • Modular

Applications of Angular :

  • Web Applications
  • Desktop Applications
  • Mobile Applications

Java :

Java is an object-oriented, class-based programming language. It works on various platforms and is one of the most widely used programming languages. It is fast, powerful and secure. It is mainly used for developing applications. It is simple to use. It has a large standard library and the code written on one platform can be executed on other platforms without any modifications.

Advantages of Java :

  • Robust
  • Secure
  • Distributed
  • Multithreaded
  • High Performance

Applications of Java :

  • Web Servers and Application Servers
  • Enterprise Applications
  • Mobile Games Development

MySQL :

MySQL is a relational database management system. It is an open-sourced programming language that uses structured query language for processing the data in the database. It works on various operating systems and supports large databases. It is an essential part of almost every PHP application.

Advantages of MySQL :

  • Data Security
  • Comprehensive transactional support
  • Cost Effective
  • Portable
  • Seamless Connectivity

Applications of MySQL :

  • Ecommerce
  • Session stores
  • Content Management Systems (CMS)
  • Web applications

React :

React is a front-end JavaScript Library which is developed by Facebook. It is used for building user interfaces. It can be used as a base in the development of mobile applications or single page applications. It is the view layer of an MVC application (Model View Controller).

Advantages of React :

  • Easy to learn
  • Reusable
  • UI-centric
  • Efficient
  • Maintainable

Applications of React :

  • Dynamic web applications
  • Mobile applications
  • Single page applications

Conclusion :

The above are few programming languages which are widely used for developing web and mobile applications. These are open source languages which makes them much more popular and influential. The main benefit of an open source language is that the source code can be customized efficiently to meet the user’s requirements.

CodeLabs is a free online platform offered by GreyCampus. It provides a user-friendly environment to learn and practice new programming languages. It is beneficial for beginners as well as advanced programmers. CodeLabs has interactive resources like videos, assignments, projects etc..which makes it easy and convenient for learning.

The post Learning and coding with CodeLabs appeared first on My Programming Tutorials.


Dictionaries should be free

In the current society, education is really important and the tendency starts to show up that people are trying to get the best education quality that they can. However, in most of the countries it is impossible to get an education for free. That means that if you want to become successful in the today’s… Read More » The post Dictionaries should be free appeared first on My Programming...

In the current society, education is really important and the tendency starts to show up that people are trying to get the best education quality that they can. However, in most of the countries it is impossible to get an education for free. That means that if you want to become successful in the today’s society, you will have to start paying money all the way from the first years of getting out of the kinder garden.

The thing which has also become popular among those studying at schools and colleges is learning of the foreign languages. That is a thing which is told to help you a lot in the future if you will have an ability to visit a place abroad. However, people say that even if you will not have that opportunity given to you, you will still be able to learn a lot by studying the second or third foreign language. The main argument is the fact that you will be learning about a new culture, while learning the language. You will find out about the new countries and their cultures when learning some words that do not happen to be real in your home country.

So, how does all of this apply to the topic of the text. Well, we can call many various ways of studying the languages, but one of the oldest and yet the best ways that you will find nowadays is the dictionary method. It has been proven that the method where you learn the new words is not that good for those who are just starting to learn the new language. Yet with the learning of the groups of words, and also the single ones later on in the process of studying, you can easily become pretty fluent in the language you are studying. The other great thing about the dictionary method is the fact that if you add it to the other methods, it will make the learning process way easier. Therefore, such an old and not really efficient method can still exist in the current learning variety.

So, why dictionaries should be free in the current society. Well, that is pretty simple. They are the only way which can be used by poor to learn the new languages. Yet, with the price of some advanced dictionaries, the poorer people are left without a chance to learn something a little over the basics. And many services are already trying to provide help with such works. For example, some volunteer programs are giving out dictionaries to the poor and those in need. For students many various programs exist, which help with their languages. For those looking for a job it is a little harder, as they have no time to actually learn something, because of their look for a job. Therefore, such people should try to use the cover letter writing service in order to save their time and do the stuff they actually need, while they can still study the foreign language a little later.

The other great reason for starting a free distribution of dictionaries is the fact that many foreign tourists come into the new countries with them, and they definitely require some help from the locals at most of their period of staying abroad. And the problem is that many of them do not know the local language or at least English, or the locals might not know how to communicate with the strangers. Moreover, many travellers travel around the world with literally no money, meaning that they would not be able to even get the simplest help from the locals. That brings us to the point where we can say that dictionaries are going to be useful for those travelling on a low budget. It will definitely help the tourists to stay informed in the foreign country and have some help from the people who they are going to be surrounded by. Also, that will help a lot with the getting of new friends. Even if you can communicate well with your friends from abroad, using one of the words from their language will definitely boost the morale of the group, and that will help to keep the nice relations between the friends.

The topic of friendship is actually a great reason to make dictionaries free. People, especially the new generations are going to be able to talk to the people from abroad, which is always good for both of those talking, as they are going to learn a lot of new stuff about each other cultures, and at the same time they will be able to communicate on any of the topics of the interests that both people share. Therefore, we can say that by giving out the free knowledge in general, we can easily create new ties with people all around the world. The other reason is the fact that the companies that print can easily make a portion of dictionaries to be given out for free. They will not lose that much money to care about it. Moreover, they can create a new version of a dictionary to be less advanced, and at the same time with the soft cover, which will decrease the price of producing of such a book way lower, and that will definitely boost the PR of that company and rating in the eyes of people.

To sum everything up, we can say that there is no doubt that dictionaries should be made free, and that will not bring anything bad to any of the sides. However, the modern companies are so scared to lose the money that they would never risk making such a PR move, because it requires some money invested into something which might not bring too many people in. Yet, we all know that free dictionaries will give many people a chance to know much more.

The post Dictionaries should be free appeared first on My Programming Tutorials.


Web Notifications Using Laravel and Pusher

Web notification is a particular message that generates from a website, whenever any update or important message is shared on the app. These messages pop up on your desktop or device even when the respective page is not opened on your current browser. These push notifications are a great addition to the traditional email and… Read More » The post Web Notifications Using Laravel and Pusher appeared first on My Programming...

Web notification is a particular message that generates from a website, whenever any update or important message is shared on the app. These messages pop up on your desktop or device even when the respective page is not opened on your current browser.

These push notifications are a great addition to the traditional email and marketing campaigns. As a user is notified with a push notification every time whenever any update is generated and the users just have to click on that to be notified about any update.

Pusher

Pusher is a hosted service that allows web and mobile applications to add real time data to its live functionality. It works as a real time correspondent between the servers and clients. It establishes persistent connections with the clients on HTTP using WebSocket, therefore, whenever your server receives new data, it gets instantly passed on to the respective clients for maintaining live data concurrency.

In order to integrate in all major languages and frameworks, Pusher offers several libraries to achieve the integration, including libraries of PHP, Ruby, Python, Java, .NET, Go and Node for the server, and JavaScript, Objective-C (iOS) and Java (Android) for the client.

Being known as a highly scalable real time solution for apps, Pusher first came to prominence in 2010 and since then it has continued to remain as the top choice for many. The list of its happy customers includes GitHub, MailChimp, CodeShip, The Financial Times, UserVoice, Travis CI and many others.

Pusher Real-time Use Cases

Pusher has a number of common use cases for real-time web technologies including:

  1. Activity Streams
  2. Data Visualisations/Dashboards
  3. Notifications & Signalling
  4. Collaborative Apps
  5. Chat
  6. Multiplayer Games

The simplest use case of Pusher is the real time notifications. Whenever something relevant occurs according to the website user’s journey, it automatically pops up a notification for the event. This is the same functionality we have seen on Twitter, Facebook and in many other social media platforms for years.

Notification can also be seen as a form of signaling, as it does not contains any organized representation in the UI of the application, but still triggers a reaction within an application.

As far as the current social web apps are concerned, it is very common to have interactive real time notifications. We have the examples of Facebook, Twitter and other social networking sites, which support integration of creative built-in notification systems within them. In this regard, Pusher is one of the most used and popular services which helps you incorporate real-time notifications to your apps and helps you make them more lively and interactive.

In this blog, I will demonstrate about how to implement real time notification system using Laravel and Pusher.

Prerequisites

For the purpose of this tutorial, I assume that you have a Laravel application installed on a web server. My setup is:

  • Laravel 5.5
  • Pusher

I have decided to host my Laravel application on PHP MySQL hosting. It has great devstack and is known for its highly secured platform. You can also try out Cloudways for free by signing up for an account

Setup your Pusher Account

After successfully completing Laravel installation, now let’s create a Pusher account to get API key and other necessary credentials.

Web Notifications

Setup Pusher in Laravel application

After completing the signup process, carefully note down all the credentials including API key, secret key and others. Then open SSH command interface and write down the following command:

Web Notifications Laravel

.env
Once the composer finishes its process, you can configure Laravel and Pusher. Open the .env file from the root directory of Laravel app and update its values to the desired ones.

// Get the credentials from your pusher dashboard
PUSHER_APP_ID=XXXXX
PUSHER_APP_KEY=XXXXXXX
PUSHER_APP_SECRET=XXXXXXX

Web Notifications Pusher

Create Notification Event

First of all, you must create an Event class that could broadcast to Pusher from your live Laravel application. Also remember that you can easily eradicate Events from anywhere in the application.

php artisan make:event Notification

The above-mentioned code will create a new Notification class in the app/Events directory. Open the contents of the file and update as shown below:

<?php

namespace App\Events;

use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class Notification implements ShouldBroadcast{
    use Dispatchable, InteractsWithSockets, SerializesModels;
    public $username;
    public $message;

    public function __construct(){
        //your variables
    }

    public function broadcastOn(){
        return ['notification'];
    }
}

In the above-mentioned code, I have created a ShouldBroadcast interface which defines Laravel that the broadcasting of event should be with using whatever driver, which I have configured in the configuration file.

I have also created a constructor which accepts two parameters (username and verb). I have assigned these variables to class properties which also have the same name. Do remember to set the visibility of these properties to public, because they will be ignored if they aren’t set to public.

Lastly, I have set the channel name to broadcast on.

Create Controller

Now let’s create a controller, which will hold notification code logic. Open the SSH command terminal and paste the following command.

.$ php artisan make:controller PusherNotificationController

After successfully creating the controller, paste the following code in controller file.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Pusher\Pusher;

class PusherNotificationController extends Controller{

    public function sendNotification(){
        //Remember to change this with your cluster name.
        $options = array(
            'cluster' => 'ap2',
            'encrypted' => true
        );

        //Remember to set your credentials below.
        $pusher = new Pusher(
            'key',
            'secret',
            'app_id', $options
        );

        $message= "Hello Cloudways";

        //Send a message to notify channel with an event name of notify-event
        $pusher->trigger('notification', 'notification-event', $message);
    }
}

It’s time to add Pusher in the controller. You will have to setup cluster and other credentials like secret key, API etc in your controller as well.

Afterwards, you can publish to a channel and can define a specific name for that channel. For this particular tutorial, I have given channel the name of ‘Notification’, and ‘Notification Event’ as the event name. You can also change these names to any other name according to your preference. Do remember to always use the same channel name and event name in your front end clients.

Setup Route

Now I will show you how to add notification route to the web.php file, which I will use to send notifications using Pusher.

//web.php

Route::get('/notification', 'PusherNotificationController@sendNotification');

Create View

Finally after setting up controller and required routes, now let’s move to create view. Working on welcome.blade.php, paste the below following code in your view file.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Real-time notifications in Laravel using Pusher</title>

</head>
<body>
    <h1>Real-time notifications using Pusher In Laravel</h1>

    <!-- Incldue Pusher Js Client via CDN -->
    <script src="https://js.pusher.com/4.2/pusher.min.js"></script>
    <!-- Alert whenever a new notification is pusher to our Pusher Channel -->

    <script>
        //Remember to replace key and cluster with your credentials.
        var pusher = new Pusher('key', {
            cluster: 'ap2',
            encrypted: true
        });

        //Also remember to change channel and event name if your's are different.
        var channel = pusher.subscribe('notification');
        channel.bind('notification-event', function(message) {
            alert(message);
        });

    </script>
</body>
</html>

Now, let’s open up a new tab and visit www.yourdomain/notification while having the www.yourdomain.dev/welcome open in another tab and you should see the alert!.

To see the alert, open a new tab and visit www.yourdomain/notification while having the www.yourdomain.dev/welcome open on one tab. It will definitely show the alert and hence it will confirm the process mentioned in the preceding paragraphs.

Summing Up

In this blog, I have demonstrated how to implement real time notifications in a Laravel app using Pusher. Because Pusher allows us to add more live functionality to our apps and helps make it more interactive, popular social apps like Facebook and Twitter have live web notifications system integrated in their platform. Hence, using Pusher, we can also implement the same functionality in our apps and can enhance the real time interaction while using them.

If you still have more questions regarding this blog, or you want to contribute more on this topic, do feel free to share your thoughts and comments in the comments section below.

The post Web Notifications Using Laravel and Pusher appeared first on My Programming Tutorials.


How To Create Infinite Scroll Pagination With PHP And Ajax

In this tutorial, we are going to learn that how to create infinite scroll pagination with PHP and Ajax. All of you probably must have seen this feature in some websites that you can load more content by just scrolling down. It can be possible via AJAX. I hope all of you guys will be familiar with… Read More » The post How To Create Infinite Scroll Pagination With PHP And Ajax appeared first on My Programming...

In this tutorial, we are going to learn that how to create infinite scroll pagination with PHP and Ajax.

All of you probably must have seen this feature in some websites that you can load more content by just scrolling down.

It can be possible via AJAX. I hope all of you guys will be familiar with Ajax, if not please see what actually an AJAX is?

Let me show you some live examples of infinite scroll pagination, as you are a regular user of Facebook & Twitter etc. I bet you noticed that they use this kinda pagination. When you scroll down they load more contents on your timeline.

View Demo

infinite scroll pagination with php and ajax

In my previous article, I have covered the pagination with PHP and MySql, If you have not read it yet, then I suggest you read that article first. Because the pagination part will be done by PHP itself.

Requirements to create infinite scroll pagination with PHP and Ajax

1. GIF Loader

I have used Preloaders in this article. Preloader provides almost all type of animated GIF Loaders. It is necessary to show a loading process while fetching data asynchronously.

2. A jQuery plugin called Inview

Inview is a JQuery Plugin, which is designed to fire an event as soon as the targeted element appears on the user’s viewport.

You must have JQuery installed in your page to work with Inview. The important thing is, it works only with jQuery 1.8 & upwards. To learn more about Inview, visit Github jquery.inview.

Usage of Inview

$('#target_element_id').on('inview', function(event, isInView) {
    if (isInView) {

        // element is now visible in the viewport

    } else {

        // element has gone out of viewport

    }
});

Let’s dig into actual coding

1. HTML part

<div id="response">

    <!-- response(next page's data) will get appended here -->

    <!--we need to populate some initial data-->
    <?php
        $conn=mysqli_connect("localhost","my_user","my_password","my_db");
        // Check connection
        if (mysqli_connect_errno()){
            echo "Failed to connect to MySQL: " . mysqli_connect_error();
            die();
        }
        $sql = "SELECT * FROM table LIMIT 5";
        $res_data = mysqli_query($conn,$sql);
        while($row = mysqli_fetch_assoc($res_data)){
            echo '<div>Demo'.$row["id"].'</div>';
        }
        mysqli_close($conn);
    ?>

</div>

<input type="hidden" id="pageno" value="1">
<img width='100%'  id="loader" src="loader.svg">

Lets split above HTML snippet and see what actually they will perform. So here we have Three elements #response, #pageno & #loader.

#response element would be the container for our fetched data. We will use AJAX request to fetch next page’s data and append it in #response element.

#pageno is a kind of page number counter, we are using it to identify that how much pages have loaded. We have set its default value to “1” so that it loads the first page first.

#loader will be placed at the last of the results as you can see it in the HTML snippet. When the user scrolls down, the Ajax function that will bring the data of the next page will get fired as soon as the #loader comes in the viewport.

2. AJAX JQuery Part

var nextPage = parseInt($('#pageno').val())+1;

$.ajax({
    type: 'POST',
    url: 'pagination.php',
    data: {
        pageno: nextPage
    },
    success: function(data){
        if(data != ''){							 
            $('#response').append(data);
            $('#pageno').val(nextPage);
        } else {								 
           $("#loader").hide();
        }
    }
});

Every time when #loader appears in the browser’s viewport then the above Ajax function gets fired and sends a POST request to the pagination.php file.

We are sending a nextPage number along with the POST request so that the pagination.php file can understand which page to load.

When execution of the Ajax function gets finished then pagination.php file returns next page’s data. We need to append that data in our #response element as you can see in the above snippet.

3. PHP part

$pageno = $_POST['pageno'];

$no_of_records_per_page = 10;
$offset = ($pageno-1) * $no_of_records_per_page;

As you can see from here the PHP pagination part has started, as I have suggested earlier you should read my previous article pagination with PHP and MySQL.

The SQL Query for Pagination

$sql = "SELECT * FROM table LIMIT $offset, $no_of_records_per_page";

Let’s assemble the PHP pagination codes

We are going to put all the PHP codes in the pagination.php file, so go ahead and create the pagination.php file and put below codes into it.

<?php

    $pageno = $_POST['pageno'];

    $no_of_records_per_page = 10;
    $offset = ($pageno-1) * $no_of_records_per_page;

    $conn=mysqli_connect("localhost","my_user","my_password","my_db");
    // Check connection
    if (mysqli_connect_errno()){
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
        die();
    }

    $sql = "SELECT * FROM table LIMIT $offset, $no_of_records_per_page";
    $res_data = mysqli_query($conn,$sql);

    while($row = mysqli_fetch_array($res_data)){

        echo '<div>Demo'.$row["id"].'</div>';

    }

    mysqli_close($conn);

?>

so PHP part has been done here.

Let’s assemble the Html and JQuery codes

<!DOCTYPE html>
<html>
<head>
    <title>Infinite Scroll Demo</title>

    <!-- JQuery CDN -->
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

    <!-- Inview Js (jquery.inview.js) -->
    <script src="jquery.inview.js"></script>

    <style>
        #response div{
            border: 1px solid lightgrey;
            height: 80px;
            margin-bottom: 5px;
            padding: 50px 0px 0px 0px;
            text-align: center;
        }
        #loader{
            display: block;
            margin: auto;
        }
    </style>
</head>
<body>

    <div id="response">

        <!-- response(next page's data) will get appended here -->

        <!--we need to populate some initial data-->
        <?php
            $conn=mysqli_connect("localhost","my_user","my_password","my_db");
            // Check connection
            if (mysqli_connect_errno()){
                echo "Failed to connect to MySQL: " . mysqli_connect_error();
                die();
            }
            $sql = "SELECT * FROM table LIMIT 5";
            $res_data = mysqli_query($conn,$sql);
            while($row = mysqli_fetch_assoc($res_data)){
                echo '<div>Demo'.$row["id"].'</div>';
            }
            mysqli_close($conn);
        ?>
    </div>

     <input type="hidden" id="pageno" value="1">
     <img width='100%'  id="loader" src="loader.svg">
     <script>
         $(document).ready(function(){
             $('#loader').on('inview', function(event, isInView) {
                 if (isInView) {
                     var nextPage = parseInt($('#pageno').val())+1;
                     $.ajax({
                         type: 'POST',
                         url: 'pagination.php',
                         data: { pageno: nextPage },
                         success: function(data){
                             if(data != ''){							 
                                 $('#response').append(data);
                                 $('#pageno').val(nextPage);
                             } else {								 
                                 $("#loader").hide();
                             }
                         }
                     });
                 }
             });
         });
     </script>
</body>
</html>

There is a JavaScript Plugin called Infinite Scroll available to save your time, but I personally won’t recommend you to use this.

I know you all probably would wondering,  why would I suggest that?

It is because this JavaScript plugin contains a JS file and by using this plugin you might end up with some extra kilobytes, which definitely gonna hamper your website’s load time.

That’s all folks!!!, If you find this article helpful, don’t forget to share and subscribe us.

The post How To Create Infinite Scroll Pagination With PHP And Ajax appeared first on My Programming Tutorials.


Link to Category: Programming Blogs

Or if you prefer use one of our linkware images? Click here

Social Bookmarks


Available Upgrade

If you are the owner of My Programming Tutorials, or someone who enjoys this blog why not upgrade it to a Featured Listing or Permanent Listing?


We maximize your reach, by maximizing your feed and new post by broadcasting!