g10dra's Blog

Showing 1 to 5 of 7 blog articles.
  25959 views · 5 years ago

![PHP CHAT WITH SOCKETS](https://images.ctfassets.net/vzl5fkwyme3u/71dBtxsZPdBnAn8UgQTyRR/75ca0c2ab27af41ffc82b17d1be264d7/AdobeStock_265642631.jpeg?w=1000)

Hey Friends,

I am sharing a very interesting blog on how to create a chat system in php without using ajax. As we all know ajax based chat system in php is not a good solution

because it **increases the server load and redundant xhr calls** on our server.

Instead, I am going to use sockets for incoming messages from and send messages to another user. So lets try them out using the following steps:

### Step 1: Cross check in php.ini that sockets extension is enabled

```

;extension=sockets

/ /remove semicolon from very start of the extension like

extension=sockets

```

### Step 2: Create `server.php` file

This file will handle the incoming and outgoing messages on sockets, Add following variables in to...

  39907 views · 5 years ago

![Securing PHP RESTful APIs using Firebase JWT Library](https://images.ctfassets.net/vzl5fkwyme3u/4oaGx3XTrH7kq4KkQbQPQ6/87f8b47b39e42dfdd93e111aa4f91e9f/AdobeStock_191967596.png?w=1000)

Hello Guys,

In our [Last Blog Post](https://nomadphp.com/blog/69/create-simple-restful-apis-using-php-amp-mysql), we have created restful apis,But not worked on its security and authentication. Login api can be public but after login apis should be authenticate using any secure token. one of them is JWT, So i am providing the Steps for Create and use JWT Token in our already created API.

Now its time To Implement JWT Authentication IN our Api, So these are the steps to implement it in our already created Apis

### Step 1:Install and include Firebase JWT(JSON WEB TOKEN) in our project with following composer command        

``` composer require firebase/php-jwt ```

include the composer insta...

  16474 views · 5 years ago

![Implement Web Push Notification in PHP using W3C provided Notification API](https://images.ctfassets.net/vzl5fkwyme3u/ERmW7y6S781gcWIiFjTRn/de1c1aeb3c79093210828760fc373ab2/AdobeStock_152541972.png?w=1000)

Hi Guys,

I am sharing you the simple steps by which you can broadcast the web push notifications to your subscriber. In this tutorial we are making a subscriber form and saving information using Ajax and PHP and then through a server side code returning response to current logged in user and showing notification to that user.

**Following are the steps to build this system**

#### 1. Create a database, I am creating db with name 'web_notifications'

Creating subscribers and notifications tables using following sql statements

```

CREATE TABLE IF NOT EXISTS `subscribers` (

`id` int(11) NOT NULL,

`name` varchar(255) NOT NULL,

`email` varchar(255) NOT NULL,

`createdAt`...

  8202 views · 5 years ago

![Standalone PHP Class for Managing Session Based Multiple Cart](https://images.ctfassets.net/vzl5fkwyme3u/5eJ0LsF3z7wkHhDaRBVCtM/1914842168ffa3b33109e930fda9fcd8/AdobeStock_214539382.jpeg?w=1000)

Hi Guys,

I am sharing you a standalone class for managing a session based cart system. In this class I have provided multiple methods for adding, updating and deleting the products. and By using this class you may manage multiple cart objects with different data only you need to pass a different key in constructor of that class.

### Let me share you the How can we use that Class:

#### Include The cart class

```php

require 'PhpKart.class.php';

```

![](https://images.ctfassets.net/vzl5fkwyme3u/3dJiwaSO68OVV0OLHX8HJO/59d5c9c08427ad7c4c0a036523191a7b/transp.png?h=20)

#### Create a Cart Object initializing the Cart base key name, by using different keys we can manage multiple cart data in a same proj...

  76059 views · 5 years ago

![Create Simple RESTful APIs using PHP & MySQL](https://images.ctfassets.net/vzl5fkwyme3u/5s6X92LpF8dGGVZEnXGRK0/387bfe60541987d308e8201ca5bb5d3f/api_blog_post.png?w=1000)

Hi Guys,

I am sharing you the way to create simple resful apis using php and mysql. We are creating 2 apis here

First is to Loggin a existing user and second is to get list of written blogs by logged in user.

#### Create any database, i am taking ```news``` as the database name here, After it create following 2 tables inside it.

```

CREATE TABLE `users` (

`id` int(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,

`name` varchar(100),

`email` varchar(100),

`password` varchar(100),

`createdAt` datetime NOT NULL,

`updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP

);

CREATE TABLE `blogs` (

`id` int(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,

`user_id` int(11),

`title` varchar(2...