How To Create a Sudo User on Ubuntu

How To Create a Sudo User on Ubuntu

The sudo command provides a mechanism for granting administrator privileges, ordinarily only available to the root user, to normal users. This guide will show you the easiest way to create a new user with sudo access on Ubuntu, without having to modify your server’s sudoers file. If you want to configure sudo for an existing user, simply skip to step 3.

Steps to Create a New Sudo User

  1. Log in to your server as the root user.
    • ssh root@server_ip_address
  2. Use the adduser command to add a new user to your system.Be sure to replace username with the user that you want to create.
    • adduser username
    • Set and confirm the new user’s password at the prompt. A strong password is highly recommended! Set password prompts: Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully
    • Follow the prompts to set the new user’s information. It is fine to accept the defaults to leave all of this information blank. User information prompts: Changing the user information for username Enter the new value, or press ENTER for the default Full Name []: Room Number []: Work Phone []: Home Phone []: Other []: Is the information correct? [Y/n]
  3. Use the usermod command to add the user to the sudo group.
    • usermod -aG sudo username
    By default, on Ubuntu, members of the sudo group have sudo privileges.
  4. Test sudo access on new user account
    • Use the su command to switch to the new user account.
      • su – username
    • As the new user, verify that you can use sudo by prepending “sudo” to the command that you want to run with superuser privileges.
      • sudo command_to_run
    • For example, you can list the contents of the /root directory, which is normally only accessible to the root user.
      • sudo ls -la /root
    • The first time you use sudo in a session, you will be prompted for the password of the user account. Enter the password to proceed. Output: [sudo] password for username: If your user is in the proper group and you entered the password correctly, the command that you issued with sudo should run with root privileges.

Launch a Linux Virtual Machine

Launch a Linux Virtual Machine

with Amazon EC2

Amazon Elastic Compute Cloud (EC2) is the Amazon Web Service you use to create and run virtual machines in the cloud. AWS calls these virtual machines ‘instances’. This step-by-step guide will help you successfully launch a Linux virtual machine on Amazon EC2 within our AWS Free Tier.

Did you know? AWS made it even easier to launch a Linux virtual private server. Jumpstart your virtual machine with Amazon Lightsail >>

Manage Your AWS Resources

Sign in to the Console

Step 1: Launch an Amazon EC2 Instance


a. Click here to open the Amazon EC2 console and then click Launch Instance to create and configure your virtual machine.

launch-instance
(click to zoom)

Step 2: Configure your Instance

You are now in the EC2 Launch Instance Wizard, which will help you configure and launch your instance.


a. In this screen, you are shown options to choose an Amazon Machine Image (AMI). AMIs are preconfigured server templates you can use to launch an instance. Each AMI includes an operating system, and can also include applications and application servers.

For this tutorial, find Amazon Linux AMI and click Select.

amazon-linux-ami
(click to zoom)

b. You will now choose an instance type. Instance types comprise of varying combinations of CPU, memory, storage, and networking capacity so you can choose the appropriate mix for your applications. For more information, see Amazon EC2 Instance Types.

The default option of t2.micro should already be checked.  This instance type is covered within the Free Tier and offers enough compute capacity to tackle simple workloads. Click Review and Launch at the bottom of the page.

ec2-t2-micro
(click to zoom)

c. You can review the configuration, storage, tagging, and security settings that have been selected for your instance. While you have the option to customize these settings, we recommend accepting the default values for this tutorial.

Click Launch at the bottom of the page.

review-launch
(click to zoom)

d. On the next screen you will be asked to choose an existing key pair or create a new key pair. A key pair is used to securely access your Linux instance using SSH. AWS stores the public part of the key pair which is just like a house lock. You download and use the private part of the key pair which is just like a house key.

Select Create a new key pair and give it the name MyKeyPair. Next click the Download Key Pair button.

After you download the MyKeyPair key, you will want to store your key in a secure location. If you lose your key, you won’t be able to access your instance. If someone else gets access to your key, they will be able to access your instance.

Select your operating system below to see instructions on where to save your SSH key.

  • Windows Windows users:We recommend saving your key pair in your user directory in a sub-directory called .ssh (ex. C:\user\{yourusername}\.ssh\MyKeyPair.pem).Tip: You can’t use Windows Explorer to create a folder with a name that begins with a period unless you also end the folder name with a period. After you enter the name (.ssh.), the final period is removed automatically.
  • Mac / Linux

After you have stored your key pair, click Launch Instance to start your Linux instance.

Getting-Started-VM9
(click to zoom)

e. Click View Instances on the next screen to view your instances and see the status of the instance you have just started.

Getting-Started-VM8
(click to zoom)

f. In a few minutes, the Instance State column on your instance will change to “running” and a Public IP address will be shown. You can refresh these Instance State columns by pressing the refresh button on the right just above the table. Copy the Public IP address of your AWS instance, so you can use it when we connect to the instance using SSH in Step 3.

Getting-Started-VM6
(click to zoom)

Step 3: Connect to your Instance


After launching your instance, it’s time to connect to it using SSH.

Windows users:  Select Windows below to see instructions for installing Git Bash which includes SSH.

Mac/Linux user: Select Mac / Linux below to see instructions for opening a terminal window.

  • Windows a. Download Git for Windows here. Run the downloaded installer accepting the default settings (this will install Git Bash as part of Git). Getting-Started-VM1 (click to zoom) b. Right click on your desktop (not on an icon or file) and select Git Bash Here to open a Git Bash command prompt. Getting-Started-VM2 (click to zoom) c. Use SSH to connect to your instance. In this case the user name is ec2-user, the SSH key is stored in the directory we saved it to in step 2 part d, and the IP address is from step 2 part f. The format is ssh -i {full path of your .pem file} ec2-user@{instance IP address}.Enter ssh -i ‘c:\Users\yourusername\.ssh\MyKeyPair.pem’ ec2-user@{IP_Address} (ex. ssh -i ‘c:\Users\adamglic\.ssh\MyKeyPair.pem’ ec2-user@52.27.212.125)You’ll see a response similar to the following:The authenticity of host ‘ec2-198-51-100-1.compute-1.amazonaws.com (10.254.142.33)’ can’t be established. RSA key fingerprint is 1f:51:ae:28:df:63:e9:d8:cf:38:5d:87:2d:7b:b8:ca:9f:f5:b1:6f. Are you sure you want to continue connecting (yes/no)?Type yes and press enter. Getting-Started-VM4 (click to zoom) You’ll see a response similar to the following:Warning: Permanently added ‘ec2-198-51-100-1.compute-1.amazonaws.com’ (RSA) to the list of known hosts.
    You should then see the welcome screen for your instance and you are now connected to your AWS Linux virtual machine in the cloud. Getting-Started-VM7 (click to zoom)
  • Mac / Linux Getting-Started-CLI-OSX1 Getting-Started-VM3 Getting-Started-VM4 Getting-Started-VM7

Step 4: Terminate Your Instance

You can easily terminate the instance from the EC2 console. In fact, it is a best practice to terminate instances you are no longer using so you don’t keep getting charged for them.


a. Back on the EC2 Console, select the box next to the instance you created.  Then click the Actions button, navigate to Instance State, and click Terminate.

launch-windows-vm-18
(click to zoom)

b. You will be asked to confirm your termination – select Yes, Terminate.

Note: This process can take several seconds to complete.  Once your instance has been terminated, the Instance State will change to terminated on your EC2 Console.

Important gitlab commands

Important gitlab commands

Command line instructions

Git global setup
git config --global user.name "aditya kumar singh"
git config --global user.email "aditya@apptology.in"
Create a new repository
git clone http://gitlab.apptology.com/aditya.kumar/garysir.git
cd garysir
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Existing folder or Git repository
cd existing_folder
git init
git remote add origin http://gitlab.apptology.com/aditya.kumar/garysir.git
git add .
git commit
git push -u origin master


example :

git add file or folder or .
git commit -m "message"
git push -u origin master


How To Create A Simple REST API in PHP? Step By Step Guide!

How To Create A Simple REST API in PHP? Step By Step Guide!

Previously, we learned how to create, read, update and delete database records (CRUD operations) with our PHP, MySQL & OOP CRUD Tutorial.

Today, before we go to JavaScript programming, we will learn how to create a simple REST API in PHP. Enjoy our step-by-step tutorial below!

This post covers the following topics:

1.0 Project Overview
1.1 What is REST API?
1.2 Why do we need REST API?
1.3 Where REST API is used?
1.4 REST API in our tutorials

2.0 File Structure

3.0 Setup the Database
3.1 Create Categories Table
3.2 Dump Data For Categories Table
3.3 Products Table
3.4 Dump Data For Products Table
3.5 Connect to database

4.0 Read Products
4.1 Product Object
4.2 Create “read.php” file
4.3 Add Product “read()” method
4.4 Output

5.0 Create Product
5.1 Create create.php file
5.2 Product create() method

6.0 Read One Product
6.1 Create read_one.php file
6.2 Product readOne() method
6.3 Output

7.0 Update product
7.1 Create “update.php” file
7.2 Product update() method

8.0 Delete Product
8.1 Create “delete.php” file
8.2 Product delete() method

9.0 Search Products
9.1 Create “search.php” file
9.2 Create “search()” method
9.3 Output

10.0 Paginate Products
10.1 Create “read_paging.php” file
10.2 Create “core.php” file
10.3 Create “readPaging()” method
10.4 Create “count()” method
10.5 Get “paging” array
10.6 Output

11.0 Read Categories
11.1 Category object
11.2 Create “read.php” file
11.3 Category “read()” method
11.4 Output

12.0 Download Source Codes
13.0 What’s Next?
14.0 Related Tutorials
15.0 Notes

1.0 PROJECT OVERVIEW

1.1 What is REST API?

To define “REST API”, we have to know what is “REST” and what is “API” first. I’ll do my best to explain it in simple terms because REST has a lot of concepts inside of it that could mean a lot of things.

REST stands for “REpresentational State Transfer”. It is a concept or architecture for managing information over the internet. REST concepts are referred to as resources. A representation of a resource must be stateless. It is usually represented by JSON. This post is worth reading: How I Explained REST to My Wife?

API stands for “Application Programming Interface”. It is a set of rules that allows one piece of software application to talk to another. Those “rules” can include create, read, update and delete operations. If you want to learn more, watch the video below and read the musiccritic’s YouTube camera review if you interested on making some videos.

REST API enable your application to cooperate with one or several different applications using REST concepts. If you want to learn more, watch the video below.

1.2 Why do we need REST API?

In many applications, REST API is a need because this is the lightest way to create, read, update or delete information between different applications over the internet or HTTP protocol. This information is presented to the user in an instant especially if you use JavaScript to render the data on a webpage.

1.3 Where REST API is used?

REST API can be used by any application that can connect to the internet. If data from an application can be created, read, updated or deleted using another application, it usually means a REST API is used.

1.4 REST API in our tutorials

A REST API is needed for our JavaScript programming tutorials. This post will help you a lot with that need. Our JavaScript programming tutorials includes the following topics:

But don’t mind those topics for now. We will do it one step at a time. You don’t need to learn all of it as well. Just choose what you need to learn.

Also, please note that this PHP REST API is not yet in its final form. We still have some work to do with .htaccess for better URLs and more.

But one thing is for sure, this source codes is good enough and works for our JavaScript tutorials.

2.0 FILE STRUCTURE

At the end of this tutorial, we will have the following folders and files.
├─ api/
├─── config/
├────── core.php – file used for core configuration
├────── database.php – file used for connecting to the database.
├─── objects/
├────── product.php – contains properties and methods for “product” database queries.
├────── category.php – contains properties and methods for “category” database queries.
├─── product/
├────── create.php – file that will accept posted product data to be saved to database.
├────── delete.php – file that will accept a product ID to delete a database record.
├────── read.php – file that will output JSON data based from “products” database records.
├────── read_paging.php – file that will output “products” JSON data with pagination.
├────── read_one.php – file that will accept product ID to read a record from the database.
├────── update.php – file that will accept a product ID to update a database record.
├────── search.php – file that will accept keywords parameter to search “products” database.
├─── category/
├────── read.php – file that will output JSON data based from “categories” database records.
├─── shared/
├────── utilities.php – file that will return pagination array.

3.0 SETUP THE DATABASE

Using PhpMyAdmin, create a new “api_db” database. Yes, “api_db” is the database name. After that, run the following SQL queries to create new tables with sample data.

3.1 Create Categories Table


CREATE TABLE IF NOT EXISTS `categories` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(256) NOT NULL,
  `description` text NOT NULL,
  `created` datetime NOT NULL,
  `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ;

3.2 Dump Data For Categories Table

INSERT INTO `categories` (`id`, `name`, `description`, `created`, `modified`) VALUES
(1, 'Fashion', 'Category for anything related to fashion.', '2014-06-01 00:35:07', '2014-05-30 17:34:33'),
(2, 'Electronics', 'Gadgets, drones and more.', '2014-06-01 00:35:07', '2014-05-30 17:34:33'),
(3, 'Motors', 'Motor sports and more', '2014-06-01 00:35:07', '2014-05-30 17:34:54'),
(5, 'Movies', 'Movie products.', '0000-00-00 00:00:00', '2016-01-08 13:27:26'),
(6, 'Books', 'Kindle books, audio books and more.', '0000-00-00 00:00:00', '2016-01-08 13:27:47'),
(13, 'Sports', 'Drop into new winter gear.', '2016-01-09 02:24:24', '2016-01-09 01:24:24');

3.3 Products Table


CREATE TABLE IF NOT EXISTS `products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(32) NOT NULL,
  `description` text NOT NULL,
  `price` decimal(10,0) NOT NULL,
  `category_id` int(11) NOT NULL,
  `created` datetime NOT NULL,
  `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=65 ;

3.4 Dump Data For Products Table


INSERT INTO `products` (`id`, `name`, `description`, `price`, `category_id`, `created`, `modified`) VALUES
(1, 'LG P880 4X HD', 'My first awesome phone!', '336', 3, '2014-06-01 01:12:26', '2014-05-31 17:12:26'),
(2, 'Google Nexus 4', 'The most awesome phone of 2013!', '299', 2, '2014-06-01 01:12:26', '2014-05-31 17:12:26'),
(3, 'Samsung Galaxy S4', 'How about no?', '600', 3, '2014-06-01 01:12:26', '2014-05-31 17:12:26'),
(6, 'Bench Shirt', 'The best shirt!', '29', 1, '2014-06-01 01:12:26', '2014-05-31 02:12:21'),
(7, 'Lenovo Laptop', 'My business partner.', '399', 2, '2014-06-01 01:13:45', '2014-05-31 02:13:39'),
(8, 'Samsung Galaxy Tab 10.1', 'Good tablet.', '259', 2, '2014-06-01 01:14:13', '2014-05-31 02:14:08'),
(9, 'Spalding Watch', 'My sports watch.', '199', 1, '2014-06-01 01:18:36', '2014-05-31 02:18:31'),
(10, 'Sony Smart Watch', 'The coolest smart watch!', '300', 2, '2014-06-06 17:10:01', '2014-06-05 18:09:51'),
(11, 'Huawei Y300', 'For testing purposes.', '100', 2, '2014-06-06 17:11:04', '2014-06-05 18:10:54'),
(12, 'Abercrombie Lake Arnold Shirt', 'Perfect as gift!', '60', 1, '2014-06-06 17:12:21', '2014-06-05 18:12:11'),
(13, 'Abercrombie Allen Brook Shirt', 'Cool red shirt!', '70', 1, '2014-06-06 17:12:59', '2014-06-05 18:12:49'),
(26, 'Another product', 'Awesome product!', '555', 2, '2014-11-22 19:07:34', '2014-11-21 20:07:34'),
(28, 'Wallet', 'You can absolutely use this one!', '799', 6, '2014-12-04 21:12:03', '2014-12-03 22:12:03'),
(31, 'Amanda Waller Shirt', 'New awesome shirt!', '333', 1, '2014-12-13 00:52:54', '2014-12-12 01:52:54'),
(42, 'Nike Shoes for Men', 'Nike Shoes', '12999', 3, '2015-12-12 06:47:08', '2015-12-12 05:47:08'),
(48, 'Bristol Shoes', 'Awesome shoes.', '999', 5, '2016-01-08 06:36:37', '2016-01-08 05:36:37'),
(60, 'Rolex Watch', 'Luxury watch.', '25000', 1, '2016-01-11 15:46:02', '2016-01-11 14:46:02');

3.5 Connect to database

Create “config” folder. Open that folder and create “database.php” file. Put the following code inside it.

<?php
class Database{
 
    // specify your own database credentials
    private $host = "localhost";
    private $db_name = "api_db";
    private $username = "root";
    private $password = "";
    public $conn;
 
    // get the database connection
    public function getConnection(){
 
        $this->conn = null;
 
        try{
            $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
            $this->conn->exec("set names utf8");
        }catch(PDOException $exception){
            echo "Connection error: " . $exception->getMessage();
        }
 
        return $this->conn;
    }
}
?>

4.0 READ PRODUCTS

4.1 Product Object

Create “objects” folder. Open that folder and create “product.php” file. Put the following code inside it.

<?php
class Product{
 
    // database connection and table name
    private $conn;
    private $table_name = "products";
 
    // object properties
    public $id;
    public $name;
    public $description;
    public $price;
    public $category_id;
    public $category_name;
    public $created;
 
    // constructor with $db as database connection
    public function __construct($db){
        $this->conn = $db;
    }
}

4.2 Create “read.php” file

Create “product” folder. Open that folder and create “read.php” file. Put the following code inside it.

<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
 
// include database and object files
include_once '../config/database.php';
include_once '../objects/product.php';
 
// instantiate database and product object
$database = new Database();
$db = $database->getConnection();
 
// initialize object
$product = new Product($db);
 
// query products
$stmt = $product->read();
$num = $stmt->rowCount();
 
// check if more than 0 record found
if($num>0){
 
    // products array
    $products_arr=array();
    $products_arr["records"]=array();
 
    // retrieve our table contents
    // fetch() is faster than fetchAll()
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
        // extract row
        // this will make $row['name'] to
        // just $name only
        extract($row);
 
        $product_item=array(
            "id" => $id,
            "name" => $name,
            "description" => html_entity_decode($description),
            "price" => $price,
            "category_id" => $category_id,
            "category_name" => $category_name
        );
 
        array_push($products_arr["records"], $product_item);
    }
 
    echo json_encode($products_arr);
}
 
else{
    echo json_encode(
        array("message" => "No products found.")
    );
}
?>

4.3 Add Product “read()” method

Open “objects” folder. Open “product.php” file. The code on the previous section will not work without the following code in “product.php” file.

Add the following method inside the “Product” class. To make sure you added it correctly, put the code before the last closing curly brace.

// read products
function read(){
 
    // select all query
    $query = "SELECT
                c.name as category_name, p.id, p.name, p.description, p.price, p.category_id, p.created
            FROM
                " . $this->table_name . " p
                LEFT JOIN
                    categories c
                        ON p.category_id = c.id
            ORDER BY
                p.created DESC";
 
    // prepare query statement
    $stmt = $this->conn->prepare($query);
 
    // execute query
    $stmt->execute();
 
    return $stmt;
}

4.4 Output

If you develop on localhost and will run the read.php file using this URL: http://localhost/api/product/read.php

You will see an output like this:

By the way, I’m using a Chrome extension called JSONView to make the JSON data readable in the browser.

5.0 CREATE PRODUCT

5.1 Create create.php file

Open “product” folder. Create a new “create.php” file. Open that file and put the following code inside it.

<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
 
// get database connection
include_once '../config/database.php';
 
// instantiate product object
include_once '../objects/product.php';
 
$database = new Database();
$db = $database->getConnection();
 
$product = new Product($db);
 
// get posted data
$data = json_decode(file_get_contents("php://input"));
 
// set product property values
$product->name = $data->name;
$product->price = $data->price;
$product->description = $data->description;
$product->category_id = $data->category_id;
$product->created = date('Y-m-d H:i:s');
 
// create the product
if($product->create()){
    echo '{';
        echo '"message": "Product was created."';
    echo '}';
}
 
// if unable to create the product, tell the user
else{
    echo '{';
        echo '"message": "Unable to create product."';
    echo '}';
}
?>

5.2 Product create() method

Open “objects” folder. Open “product.php” file. The previous section will not work without the following code inside the Product (objects/product.php) class.

// create product
function create(){
 
    // query to insert record
    $query = "INSERT INTO
                " . $this->table_name . "
            SET
                name=:name, price=:price, description=:description, category_id=:category_id, created=:created";
 
    // prepare query
    $stmt = $this->conn->prepare($query);
 
    // sanitize
    $this->name=htmlspecialchars(strip_tags($this->name));
    $this->price=htmlspecialchars(strip_tags($this->price));
    $this->description=htmlspecialchars(strip_tags($this->description));
    $this->category_id=htmlspecialchars(strip_tags($this->category_id));
    $this->created=htmlspecialchars(strip_tags($this->created));
 
    // bind values
    $stmt->bindParam(":name", $this->name);
    $stmt->bindParam(":price", $this->price);
    $stmt->bindParam(":description", $this->description);
    $stmt->bindParam(":category_id", $this->category_id);
    $stmt->bindParam(":created", $this->created);
 
    // execute query
    if($stmt->execute()){
        return true;
    }
 
    return false;
    
}

I highly recommend completing this whole tutorial first. But if you want to test the code above, you have to use our JavaScript code. The reason is our JavaScript code is designed to work with this REST API.

Please complete one of our JavaScript programming tutorials. This same concept applies to our “update” and “delete” code.

6.0 READ ONE PRODUCT

6.1 Create read_one.php file

Open “product” folder. Create new “read_one.php” file. Open that file and put the following code.

<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: access");
header("Access-Control-Allow-Methods: GET");
header("Access-Control-Allow-Credentials: true");
header('Content-Type: application/json');
 
// include database and object files
include_once '../config/database.php';
include_once '../objects/product.php';
 
// get database connection
$database = new Database();
$db = $database->getConnection();
 
// prepare product object
$product = new Product($db);
 
// set ID property of product to be edited
$product->id = isset($_GET['id']) ? $_GET['id'] : die();
 
// read the details of product to be edited
$product->readOne();
 
// create array
$product_arr = array(
    "id" =>  $product->id,
    "name" => $product->name,
    "description" => $product->description,
    "price" => $product->price,
    "category_id" => $product->category_id,
    "category_name" => $product->category_name
 
);
 
// make it json format
print_r(json_encode($product_arr));
?>

6.2 Product readOne() method

Open “objects” folder. Open “product.php” file. The previous section will not work without the following code inside the Product class.

// used when filling up the update product form
function readOne(){
 
    // query to read single record
    $query = "SELECT
                c.name as category_name, p.id, p.name, p.description, p.price, p.category_id, p.created
            FROM
                " . $this->table_name . " p
                LEFT JOIN
                    categories c
                        ON p.category_id = c.id
            WHERE
                p.id = ?
            LIMIT
                0,1";
 
    // prepare query statement
    $stmt = $this->conn->prepare( $query );
 
    // bind id of product to be updated
    $stmt->bindParam(1, $this->id);
 
    // execute query
    $stmt->execute();
 
    // get retrieved row
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
 
    // set values to object properties
    $this->name = $row['name'];
    $this->price = $row['price'];
    $this->description = $row['description'];
    $this->category_id = $row['category_id'];
    $this->category_name = $row['category_name'];
}

6.3 Output

If you develop on localhost and will run the read_one.php file using this URL: http://localhost/api/product/read_one.php?id=60

As you can see in the URL above, an ID parameter value (id=60) has to be passed.

You will see an output like this:

7.0 UPDATE PRODUCT

7.1 Create “update.php” file

Open “product” folder. Create new “update.php” file. Open that file and put the following code inside it.

<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
 
// include database and object files
include_once '../config/database.php';
include_once '../objects/product.php';
 
// get database connection
$database = new Database();
$db = $database->getConnection();
 
// prepare product object
$product = new Product($db);
 
// get id of product to be edited
$data = json_decode(file_get_contents("php://input"));
 
// set ID property of product to be edited
$product->id = $data->id;
 
// set product property values
$product->name = $data->name;
$product->price = $data->price;
$product->description = $data->description;
$product->category_id = $data->category_id;
 
// update the product
if($product->update()){
    echo '{';
        echo '"message": "Product was updated."';
    echo '}';
}
 
// if unable to update the product, tell the user
else{
    echo '{';
        echo '"message": "Unable to update product."';
    echo '}';
}
?>

7.2 Product update() method

Open “objects” folder. Open “product.php” file. The previous section will not work without the following code inside the Product class.

// update the product
function update(){
 
    // update query
    $query = "UPDATE
                " . $this->table_name . "
            SET
                name = :name,
                price = :price,
                description = :description,
                category_id = :category_id
            WHERE
                id = :id";
 
    // prepare query statement
    $stmt = $this->conn->prepare($query);
 
    // sanitize
    $this->name=htmlspecialchars(strip_tags($this->name));
    $this->price=htmlspecialchars(strip_tags($this->price));
    $this->description=htmlspecialchars(strip_tags($this->description));
    $this->category_id=htmlspecialchars(strip_tags($this->category_id));
    $this->id=htmlspecialchars(strip_tags($this->id));
 
    // bind new values
    $stmt->bindParam(':name', $this->name);
    $stmt->bindParam(':price', $this->price);
    $stmt->bindParam(':description', $this->description);
    $stmt->bindParam(':category_id', $this->category_id);
    $stmt->bindParam(':id', $this->id);
 
    // execute the query
    if($stmt->execute()){
        return true;
    }
 
    return false;
}

8.0 DELETE PRODUCT

8.1 Create “delete.php” file

Open “product” folder. Create new “delete.php” file. Open that file and put the following code inside it.

<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
 
 
// include database and object file
include_once '../config/database.php';
include_once '../objects/product.php';
 
// get database connection
$database = new Database();
$db = $database->getConnection();
 
// prepare product object
$product = new Product($db);
 
// get product id
$data = json_decode(file_get_contents("php://input"));
 
// set product id to be deleted
$product->id = $data->id;
 
// delete the product
if($product->delete()){
    echo '{';
        echo '"message": "Product was deleted."';
    echo '}';
}
 
// if unable to delete the product
else{
    echo '{';
        echo '"message": "Unable to delete object."';
    echo '}';
}
?>

8.2 Product delete() method

Open “objects” folder. Open “product.php” file. The previous section will not work without the following code inside the Product class.

// delete the product
function delete(){
 
    // delete query
    $query = "DELETE FROM " . $this->table_name . " WHERE id = ?";
 
    // prepare query
    $stmt = $this->conn->prepare($query);
 
    // sanitize
    $this->id=htmlspecialchars(strip_tags($this->id));
 
    // bind id of record to delete
    $stmt->bindParam(1, $this->id);
 
    // execute query
    if($stmt->execute()){
        return true;
    }
 
    return false;
    
}

9.0 SEARCH PRODUCTS

9.1 Create “search.php” file

Open “product” folder. Create “search.php” file. Open that file and put the following code.

<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
 
// include database and object files
include_once '../config/database.php';
include_once '../objects/product.php';
 
// instantiate database and product object
$database = new Database();
$db = $database->getConnection();
 
// initialize object
$product = new Product($db);
 
// get keywords
$keywords=isset($_GET["s"]) ? $_GET["s"] : "";
 
// query products
$stmt = $product->search($keywords);
$num = $stmt->rowCount();
 
// check if more than 0 record found
if($num>0){
 
    // products array
    $products_arr=array();
    $products_arr["records"]=array();
 
    // retrieve our table contents
    // fetch() is faster than fetchAll()
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
        // extract row
        // this will make $row['name'] to
        // just $name only
        extract($row);
 
        $product_item=array(
            "id" => $id,
            "name" => $name,
            "description" => html_entity_decode($description),
            "price" => $price,
            "category_id" => $category_id,
            "category_name" => $category_name
        );
 
        array_push($products_arr["records"], $product_item);
    }
 
    echo json_encode($products_arr);
}
 
else{
    echo json_encode(
        array("message" => "No products found.")
    );
}
?>

9.2 Create search() method

Open “objects” folder. Open “product.php” file. Add the following search() method.

// search products
function search($keywords){
 
    // select all query
    $query = "SELECT
                c.name as category_name, p.id, p.name, p.description, p.price, p.category_id, p.created
            FROM
                " . $this->table_name . " p
                LEFT JOIN
                    categories c
                        ON p.category_id = c.id
            WHERE
                p.name LIKE ? OR p.description LIKE ? OR c.name LIKE ?
            ORDER BY
                p.created DESC";
 
    // prepare query statement
    $stmt = $this->conn->prepare($query);
 
    // sanitize
    $keywords=htmlspecialchars(strip_tags($keywords));
    $keywords = "%{$keywords}%";
 
    // bind
    $stmt->bindParam(1, $keywords);
    $stmt->bindParam(2, $keywords);
    $stmt->bindParam(3, $keywords);
 
    // execute query
    $stmt->execute();
 
    return $stmt;
}

9.3 Output

Output should look like the following. Notice the sample search keyword on the URL.

Try this link: http://localhost/api/product/search.php?s=shirt

10.0 PAGINATE PRODUCTS

10.1 Create “read_paging.php” file

On the /api/product/ folder, create “read_paging.php” file.

<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
 
// include database and object files
include_once '../config/core.php';
include_once '../shared/utilities.php';
include_once '../config/database.php';
include_once '../objects/product.php';
 
// utilities
$utilities = new Utilities();
 
// instantiate database and product object
$database = new Database();
$db = $database->getConnection();
 
// initialize object
$product = new Product($db);
 
// query products
$stmt = $product->readPaging($from_record_num, $records_per_page);
$num = $stmt->rowCount();
 
// check if more than 0 record found
if($num>0){
 
    // products array
    $products_arr=array();
    $products_arr["records"]=array();
    $products_arr["paging"]=array();
 
    // retrieve our table contents
    // fetch() is faster than fetchAll()
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
        // extract row
        // this will make $row['name'] to
        // just $name only
        extract($row);
 
        $product_item=array(
            "id" => $id,
            "name" => $name,
            "description" => html_entity_decode($description),
            "price" => $price,
            "category_id" => $category_id,
            "category_name" => $category_name
        );
 
        array_push($products_arr["records"], $product_item);
    }
 
 
    // include paging
    $total_rows=$product->count();
    $page_url="{$home_url}product/read_paging.php?";
    $paging=$utilities->getPaging($page, $total_rows, $records_per_page, $page_url);
    $products_arr["paging"]=$paging;
 
    echo json_encode($products_arr);
}
 
else{
    echo json_encode(
        array("message" => "No products found.")
    );
}
?>

10.2 Create “core.php” file

This file holds our core configuration like the home URL and pagination variables.

Open the “config” folder and create “core.php” file. Open “core.php” file and place the following code.

<?php
// show error reporting
ini_set('display_errors', 1);
error_reporting(E_ALL);
 
// home page url
 
// page given in URL parameter, default page is one
$page = isset($_GET['page']) ? $_GET['page'] : 1;
 
// set number of records per page
$records_per_page = 5;
 
// calculate for the query LIMIT clause
$from_record_num = ($records_per_page * $page) - $records_per_page;
?>

10.3 Create “readPaging()” method

Open product.php file in /api/objects/ folder. Add the following method inside product class. This method will return a list of records limited to what we set in “$records_per_page” of the previous section.

// read products with pagination
public function readPaging($from_record_num, $records_per_page){
 
    // select query
    $query = "SELECT
                c.name as category_name, p.id, p.name, p.description, p.price, p.category_id, p.created
            FROM
                " . $this->table_name . " p
                LEFT JOIN
                    categories c
                        ON p.category_id = c.id
            ORDER BY p.created DESC
            LIMIT ?, ?";
 
    // prepare query statement
    $stmt = $this->conn->prepare( $query );
 
    // bind variable values
    $stmt->bindParam(1, $from_record_num, PDO::PARAM_INT);
    $stmt->bindParam(2, $records_per_page, PDO::PARAM_INT);
 
    // execute query
    $stmt->execute();
 
    // return values from database
    return $stmt;
}

10.4 Create “count()” method

Still in the product class (product.php file), add the following method. The total rows are needed to build the pagination array. It is included in the ‘paging’ computation.

// used for paging products
public function count(){
    $query = "SELECT COUNT(*) as total_rows FROM " . $this->table_name . "";
 
    $stmt = $this->conn->prepare( $query );
    $stmt->execute();
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
 
    return $row['total_rows'];
}

10.5 Get “paging” array

Create “shared” folder.
Open “shared” folder and create “utilities.php” file.
Open “utilities.php” file and put the following code.

<?php
class Utilities{
 
    public function getPaging($page, $total_rows, $records_per_page, $page_url){
 
        // paging array
        $paging_arr=array();
 
        // button for first page
        $paging_arr["first"] = $page>1 ? "{$page_url}page=1" : "";
 
        // count all products in the database to calculate total pages
        $total_pages = ceil($total_rows / $records_per_page);
 
        // range of links to show
        $range = 2;
 
        // display links to 'range of pages' around 'current page'
        $initial_num = $page - $range;
        $condition_limit_num = ($page + $range)  + 1;
 
        $paging_arr['pages']=array();
        $page_count=0;
        
        for($x=$initial_num; $x<$condition_limit_num; $x++){
            // be sure '$x is greater than 0' AND 'less than or equal to the $total_pages'
            if(($x > 0) && ($x <= $total_pages)){
                $paging_arr['pages'][$page_count]["page"]=$x;
                $paging_arr['pages'][$page_count]["url"]="{$page_url}page={$x}";
                $paging_arr['pages'][$page_count]["current_page"] = $x==$page ? "yes" : "no";
 
                $page_count++;
            }
        }
 
        // button for last page
        $paging_arr["last"] = $page<$total_pages ? "{$page_url}page={$total_pages}" : "";
 
        // json format
        return $paging_arr;
    }
 
}
?>

10.6 Output

You should see “paging” in the JSON output.

11.0 READ CATEGORIES

11.1 Create “category.php” file

Open “objects” folder. Create new “category.php” file. Put the following code inside the “category.php” file.

<?php
class Category{
 
    // database connection and table name
    private $conn;
    private $table_name = "categories";
 
    // object properties
    public $id;
    public $name;
    public $description;
    public $created;
 
    public function __construct($db){
        $this->conn = $db;
    }
 
    // used by select drop-down list
    public function readAll(){
        //select all data
        $query = "SELECT
                    id, name, description
                FROM
                    " . $this->table_name . "
                ORDER BY
                    name";
 
        $stmt = $this->conn->prepare( $query );
        $stmt->execute();
 
        return $stmt;
    }
}
?>

11.2 Create “read.php” file

Create new “category” folder. Open that folder and create new “read.php” file inside it. Open “read.php” file and put the following code.

<?php
// required header
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
 
// include database and object files
include_once '../config/database.php';
include_once '../objects/category.php';
 
// instantiate database and category object
$database = new Database();
$db = $database->getConnection();
 
// initialize object
$category = new Category($db);
 
// query categorys
$stmt = $category->read();
$num = $stmt->rowCount();
 
// check if more than 0 record found
if($num>0){
 
    // products array
    $categories_arr=array();
    $categories_arr["records"]=array();
 
    // retrieve our table contents
    // fetch() is faster than fetchAll()
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
        // extract row
        // this will make $row['name'] to
        // just $name only
        extract($row);
 
        $category_item=array(
            "id" => $id,
            "name" => $name,
            "description" => html_entity_decode($description)
        );
 
        array_push($categories_arr["records"], $category_item);
    }
 
    echo json_encode($categories_arr);
}
 
else{
    echo json_encode(
        array("message" => "No products found.")
    );
}
?>

11.3 Add Category “read()” method

Open “objects” folder. Open “category.php” file. The previous section’s code will not work without the following code inside the “category.php” file. Add the following method inside the “Category” class.

// used by select drop-down list
public function read(){
 
    //select all data
    $query = "SELECT
                id, name, description
            FROM
                " . $this->table_name . "
            ORDER BY
                name";
 
    $stmt = $this->conn->prepare( $query );
    $stmt->execute();
 
    return $stmt;
}

11.4 Output

If you develop on localhost and will run the read.php file using this URL: http://localhost/api/category/read.php

You will see an output like this:

12.0 DOWNLOAD SOURCE CODES

IF you download any source codes from our AJAX Tutorial, React Tutorial, AngularJS Tutorial or Angular 2 Tutorial , this PHP REST API source code is free and included in their respective packages.

BUT if you need to download this PHP REST API source code only, you can do it using the green download button below.

FEATURES PHP REST API
Create product YES
Read products YES
Read one product YES
Update product YES
Delete product YES
Search products YES
Read & search products with pagination YES
Create category YES
Read categories YES
Read one category YES
Update category YES
Delete category YES
Search categories YES
Read and search categories with pagination YES
FREE email support for 3 months YES
Source code updates via email YES

Email : adityaypi@yahoo.com, Mobile : +91-9555699081

Alternatives to Standard Arduino IDE: Which One To Choose?

Alternatives to Standard Arduino IDE: Which One To Choose?

The Arduino IDE is absolute genius and it’s the perfect tool for a beginner. But, what happens if you want more, if you want an alternative to this, a powerful development tool able to bring you advanced features in code efficiency and speed of development.

With the classical Arduino IDE an expert who wants to specialize in embedded software development can have a dead line in developing and debugging a project.

Another problem that can be solved with an advanced IDE is by writing code in other languages that the standard Arduino programming language. In theory, it’s not possible to write sketches in other language than the C like Arduino code, but if you write a compiler for the chip and define a series of built-in functions, you can transmit the compiled code via the serial port to the Arduino microcontroller. In this case, you can write your code in Python and uploaded it to the Arduino board, which is a good case for a developer with a lot of experience in a particular programming language.

Some of the tools explored in this article are just a front-end putting in the front of avr-gcc and avrdude, while other software are really peace of art with advanced features and a wide range of features.

An alternative to the classical Arduino IDE should have a great collection of libraries, it should able to serial communicate with the bootloader, multiple serial monitors, intellisense, provide multi-tab project where can be written libraries as one single project, and many other options for both novice and advanced users.

Electron

Electron GUI

The Electron IDE is an HTML tool written in NodeJS and HTML and designed to run as an application on your computer. The IDE tools were designed in mind with the idea of mobility. Electron can be accessed from anywhere and is available with all the library attached to the tool.

Codebender

Codebender

Like any good IDE, the Codebender provide you built-in libraries, comprehensive documentation and the freedom to monitor the serial port and upload your sketch to Arduino directly from a browser. The tool uses the clang compiler able to provide very good descriptive warnings when you have done something wrong.

Stino

Stino IDE

Stino is not a complete IDE, it’s just a plugin written for Sublime Text. But even it’s a simple plugin, it can offer a sophisticated text editor code, it can compile the code and upload the sketches in Arduino microcontroller. It is a plugin written in Python and can be run on several operating systems including Windows, Mac OS X, and Linux.

Eclipse

Eclipse

Probably Eclipse is one of the most popular IDE in the world, and most probably, it would offer the most complete features to develop libraries and complex sketches for Arduino boards. The Eclipse can provide a set of features that are not available in all IDE’s such as multi-tab project where can be written libraries at the same time and as one single project. Beside a greater flexibility in coding, the Eclipse is fast, offer great shortcuts, and is clean.

Visual Studio

Visual Studio

Compatible with all versions of the Arduino, the Visual Studio could become your favorite IDE after installation of the Visual Micro plugin designed to support all the features of the Arduino including compiler errors, upload, board selection, or multiple pde/ino files.

Gedit

Gedit [image source]

Fully compatible with Linux OS, the Gedit IDE is a highly customizable Arduino IDE that can make coding fast and fun.

Komodo Edit

Komodo Edit [image source]

With support for a wide variety of programming languages including Python, PHP, Perl, Ruby, Tcl, Javascript, …, the Komodo is a versatile editor that integrates visual debugging, unit testing tool, version control integration, and several other features that let you develop code for Arduino microcontroller.

MariaMole

MariaMole [image source]

With a lot of features such as a workspace enable to work in the same time with multiple projects and a built process configurable, the MariaMole is one of the best open-source IDE designed for professional Arduino developers. The software can be installed only on Windows OS.

Zeus

Zeus

With friendly configure options, the Zeus is a programmers editor with support for a wide range of programming languages and a set of features that can help you develop sketches for Arduino boards.

Atmel Studio

Atmel Studio

The Atmel Studio is already at the six versions and it’s a complete software development environment for Arduino able to provide a simulator, programmer, debugger, and also an editor.

AVR-GCC

AVR-GCC [image source]

AVR-GCC is a free software engineered to provide a series of libraries for use with GCC on Atmel AVR microcontrollers.

CodeBlocks

CodeBlocks

CodeBlocks is a fully compatible IDE for Arduino boards, with a set of features including Arduino core files and libraries, a compiler core files caches to speed up the compiling action, pre-configured AVR compiler toolchain, dedicated project wizard for Arduino development, it’s able to upload HEX to Arduino boards, and it can be integrated with Arduino API-level simulator.

ROBOTC for Arduino

ROBOTC for Arduino [image source]

With support for multiple other robot platforms such as LEGO and VEX robotics, the ROBOTC for Arduino is a complex IDE that support multitasking and has a built-in debugging window to access pin information and more.

Xcode

Xcode

Xcode is built for Mac OS X and is able to provide a lot of features that let you develop sketches for Arduino boards including debugging, git repository management, code snippets, self documentation, and many more features. The software is free.

ArduinoDroid – Arduino IDE

ArduinoDroid – Arduino IDE

Now you can develop Arduino sketches using an Arduino device. This Android application is a complete IDE application that lets you develop, compile and upload your code to the Arduino board.

Notepad ++
Yes, you can use the Notepad++ to develop sketches for Arduino. It cannot be used as a proper IDE with GUI and several other features, it can be used only to edit the .ino file after that you have to use the NPPexec script to run the Arduino IDE and load the sketch.

Install Vqmod in OpenCart manually (2.5+)

Install Vqmod in OpenCart manually (2.5+)

1. Backup or make a duplicate of your existing installed OpenCart files and folders in safe place.

2.Download the latest version Vqmod for Opencart  from:

https://github.com/vqmod/vqmod/releases

3. Using FTP, upload the “vqmod” folder from the zip to the root of your opencart store.Be sure the vqmod folder and the vqmod/vqcache folders are writable (either 755 or 777).

* Also be sure index.php and admin/index.php are writable.

 + If not sure which you need, first try 755.

 + If you get errors about permissions, then try 777.

4. Now, we need to modify two files. One is /index.php and another one is /admin/index.php file.

  Edit your  index.php

  FIND

// Startup

require_once(DIR_SYSTEM . ‘startup.php’);

// Application Classes

require_once(DIR_SYSTEM . ‘library/customer.php’);

require_once(DIR_SYSTEM . ‘library/currency.php’);

require_once(DIR_SYSTEM . ‘library/tax.php’);

require_once(DIR_SYSTEM . ‘library/weight.php’);

require_once(DIR_SYSTEM . ‘library/length.php’);

require_once(DIR_SYSTEM . ‘library/cart.php’);

require_once(DIR_SYSTEM . ‘library/affiliate.php’);

 REPLACE WITH

// vQmod

require_once(‘./vqmod/vqmod.php’);

VQMod::bootup();

// VQMODDED Startup

require_once(VQMod::modCheck(DIR_SYSTEM . ‘startup.php’));

// Application Classes

require_once(VQMod::modCheck(DIR_SYSTEM . ‘library/customer.php’));

require_once(VQMod::modCheck(DIR_SYSTEM . ‘library/currency.php’));

require_once(VQMod::modCheck(DIR_SYSTEM . ‘library/tax.php’));

require_once(VQMod::modCheck(DIR_SYSTEM . ‘library/weight.php’));

require_once(VQMod::modCheck(DIR_SYSTEM . ‘library/length.php’));

require_once(VQMod::modCheck(DIR_SYSTEM . ‘library/cart.php’));

require_once(VQMod::modCheck(DIR_SYSTEM . ‘library/affiliate.php’));

 Edit your admin/index.php file

FIND

// Startup

require_once(DIR_SYSTEM . ‘startup.php’);

// Application Classes

require_once(DIR_SYSTEM . ‘library/currency.php’);

require_once(DIR_SYSTEM . ‘library/user.php’));

require_once(DIR_SYSTEM . ‘library/weight.php’);

require_once(DIR_SYSTEM . ‘library/length.php’);

 REPLACE WITH

// vQmod

require_once(‘../vqmod/vqmod.php’);

VQMod::bootup();

// VQMODDED Startup

require_once(VQMod::modCheck(DIR_SYSTEM . ‘startup.php’));

// Application Classes

require_once(VQMod::modCheck(DIR_SYSTEM . ‘library/currency.php’));

require_once(VQMod::modCheck(DIR_SYSTEM . ‘library/user.php’));

require_once(VQMod::modCheck(DIR_SYSTEM . ‘library/weight.php’));

require_once(VQMod::modCheck(DIR_SYSTEM . ‘library/length.php’));

5. vQmod is now ready to use. Upload desired xml script to ‘vqmod/xml’ folder

6. Load your store homepage and verify it works.

Install Vqmod in Opencart autoinstaller.

Install Vqmod in Opencart  autoinstaller.

1. Backup or make a duplicate of your existing installed OpenCart files and folders in safe place.

2. Download the latest version of Vqmod from:

https://github.com/vqmod/vqmod/releases

look at vqmod for opencart and download latest version.

3. Using FTP, upload the “vqmod” folder from the zip to the root of your opencart store.Make sure vqmod/vqcache folders are writable (either 755 or 777).

* Also be sure index.php and admin/index.php are writable.

 + If not sure which you need, first try 755.

 + If you get errors about permissions, then try 777.

4. Goto http://www.yoursite.com/vqmod/install

5. You should get a success message.( If not, check permissions above and try again.)

6. vQmod is now ready to use. Upload desired xml script to ‘vqmod/xml’ folder

7. Load your store homepage and verify it works.

*DO NOT DELETE THE INSTALL FOLDER!

*YOU MUST RUN THE INSTALLER EVERY TIME YOU UPGRADE OPENCART!!

*THERE IS NO DANGER OF RE-RUNNING THE INSTALLER!

20 Most Demanded & Hot Selling Products in India Online

20 Most Demanded & Hot Selling Products in India Online

Online shopping is a growing trend in India and the numbers of both sellers and buyers are increasing daily by whopping percentages. According to a reliable source, India’s total online sales figure is estimated to reach the US $100 billion by 2020, and apparels would be the largest segment. Clothing even now is a major product of online sales. Other items that are in high demand of online buyers are mobile phones, consumer electronics, footwear, food and health supplements, beauty products, kitchen and home furnishings, fashion accessories, jewellery, books, toys and video games, handmade goods, and online subscriptions.

Products that are most in demand and selling online in India are:

Apparels – Dresses constitute the largest segment of all products sold online in India. Close to 35% of entire revenue generated from online sales comes from apparels and dress materials. Apparels include ladies clothes, men’s clothing, and children’s dresses.

Mobile Phones – Mobile phones are very popular items for sale on eCommerce sites. All brands and models available in the open market are also sold through online sites. For buyers, it is easy to compare among models online before buying a handset of choice.

Books – Buying a book could be really time-consuming if bought from the open market. It is easy for a buyer to locate a seller of their selected titles across eCommerce sites. Educational, fictional, and reference books from Indian as well as overseas publishers are available across eCommerce sites.

Consumer Electronics – eCommerce sites are excellent platforms for buying/selling consumer electronic goods like laptops, tablets, and digital cameras. By 2025 India is expected to become world’s 5th largest consumer durable market.

Footwear – Online is perhaps the best place to search for and buy footwear. The varieties are exhaustive and include shoes, slippers, sandals, and snickers for both ladies and gentlemen. People get to choose among leading brands from across the world.

Jewellery – Buying exclusive jewellery items is often a tough task when bought across counters. The entire process of selecting preferred items and buying from global leaders is done conveniently through eCommerce websites.

Fashion Accessories – It is obvious that after jewellery items, fashion accessories is a popular product category sold online. Belts, hand bags, purses, wallets, head bands, and watches are some of the items bought widely online by Indians.

Beauty Products – Skin care products like cream, lotion, face masks, moisturisers, and perfumes are demanded items that are sold online. Hair care products like gel, cream, colour, shampoo, dryers etc. are widely hot selling products through eCommerce sites.

Computer Hardware, Software, and Accessories – Desktops, disk drives, storage devices, printers, scanners, mouse, and switches are some of the computing devices and accessories that people buy online in India. Market’s leading brands are available to customers at hugely discounted prices.

Video Games – eCommerce sites in India are used to buy video games especially as gifts to children. Games ranging from FIFA World Cup, Grand Theft Auto, Call of Duty, and so on are all available on online sites.

Toys and Games – Online sites are a paradise for kids’ toys. Be it traditional games like snakes-n-ladders, scrabble or current generation remotely operated cars and helicopters, eStores offer every toy of your choice.

Home Decor Items – Drapes, cushion covers, furnishings, flower vases, table mats, tea coasters, rugs, carpets, wall-hangings and so on are available in online stores.

Kitchenware – Online marketplaces are widely used for buying kitchenware like utensils, crockery, cutlery, storage jars, and so on.

Household Appliances – This category of goods including burners, microwave ovens, pressure cookers, washing machines, electric irons, electric kettle, rice cookers, induction plates, etc are popularly sold online.

Sports Goods and Fitness Equipment – Recently these commodities have a lot of online buyers. Cricket bats, tennis and badminton rackets, football and basketballs, carom boards, football boots, cricket gear, hockey sticks, and so on are readily available online.

Baby Care Products – Baby care items is a huge revenue generator when it comes to online sales. Products like soap, powder, cream, oil, linen and diapers are sold extensively on online retail sites. Items like feeding bottles, teether, soothers, and pacifiers are also widely sold.

Food and Health Supplements – A recent addition to online supplies are food and health supplements. Changing life pattern has prompted many Indians to opt for food and health supplements triggering an increased demand for such items. eCommerce sites are the best option for buying such products.

Provisions – Items of daily use like rice, pulses, salt, sugar, cooking oil, spices, and toiletries are now sold online at a lesser price compared to market rates. For people with little time for visiting market regularly, such an online option is splendid.

Handmade Items – Handcrafted items such as costume jewellery, artefacts, scarves, footwear, table mats, purses etc. are gradually gaining popularity as items for online sale in India.

Subscriptions – Subscriptions to digital media like music channels, sports channels, films, and entertainment channels is a new kind of online service being offered to buyers.

eCommerce business in India is thriving and newer items are getting added to the list of commodities every day.

Seven Awesome New Features In Visual Studio 2017

Seven Awesome New Features In Visual Studio 2017

Microsoft developers have been using Visual Studio for their IDE since before .NET was even a thing. Visual Studio is twenty years old this year, and on March 7th, 2017 Microsoft released the latest version of it’s flagship developer product, Visual Studio. With this release are a bunch of new features, improvements, and exciting changes for the beloved Microsoft developer environment. Here are seven features in the new IDE that will excite developers using the development environment.

1. EditorConfig Built In

The EditorConfig project has been available for Visual Studio 2015, but it required you to install a plugin to take advantage of the code-style configuration tool. With the release of 2017, EditorConfig is now built into the IDE. This means you can simply create an .editorconfig file in the root of your solution and check it into your source control. This will get your whole team using the same code format rules (once you can all agree on what they should be).

2. New Visual Studio Installer

Visual Studio 2017 also comes with a new installer. The new installer lets you put together an install of Visual Studio customized to the type of development you’re doing. You can install only the features you will need every day and leave out things that you might never need. This is a great way to keep the IDE small and snappy.

3. Manage Visual Studio Performance

The Manage Visual Studio Performance (under the Help menu) allows you to view the performance of your Visual Studio IDE and can even give you suggestions about extensions that might be impacting the performance of your environment! This includes turning on Lightweight Solution Load, which doesn’t load all the projects in a solution when you open the solution, only when you begin to work in that project. You can still navigate through the code, but the project won’t be loaded until you actually start to work with that project. Awesome!

4. Mobile Development

With Microsoft’s acquisition of Xamarin a few years ago, .NET developers have been enjoying the Xamarin for free as a plugin to Visual Studio 2015. In Visual Studio 2017, it’s now one of the install options when installing Visual Studio! This is a signal that cross-platform, mobile development is now a first-class citizen in your Microsoft development toolbelt!

5. Live Unit Testing

Unit testing has been permeating every development stack over the last decade and Microsoft has followed the trend by making Live Unit Testing available. This means as you change your code, Visual Studio will let you know if your changes will break unit tests, or if they will not be covered by unit tests; in real time.

Running unit tests has almost always been an extra step of your development workflow, but with the Live Unit Testing indicators in your editor popping up as you edit code, it just happens. You can also click on an indicator in the editor and it will show you which tests are exercising that line of code. Unit testing for the win, anyone?

6. Better Javascript Support

With the proliferation of Javascript and Javascript frameworks like Angular, React, Ember, and Vue, it’s no surprise that VSCode has really gleaned a lot of support from the developer community. VSCode has excellent support for Javascript (ES5 and ES6) as well as framework support for Angular and React, including JSX.

Building on that win, Microsoft used the Javascript engine built into VSCode in Visual Studio 2017. This means that all the great support in VSCode is now available without switching out of your Visual Studio editor!

7. Docker Support Built-In

With the adoption of containerization, microservices, and Microsoft’s own work with Docker to help support Windows Containers, it’s no surprise that developers are looking for tighter integration with Docker for their development environments. In Visual Studio 2015 (Update 3), you could install the Visual Studio Tools For Docker and get integrated support for Docker containers. Visual Studio 2017, builds this feature in and when choosing the application template from the File -> New menu, you can choose to turn on Docker support, giving you all the goodness of the plug-in, built in to Visual Studio!

Visual Studio has always been the editor of choice for those writing .NET applications and tapping into the Microsoft ecosystem. It has always had all the tools developers need to be their best, most productive selves. Now Microsoft has done some outstanding work to include and integrate with non-Microsoft tools that developers love to use, as well as help developers discover problems in their code, and improve the performance of their IDE. With the new additions and improvements in Visual Studio 2017, developers should love it even more!