enuk

Rest API

REST (Representational State Transfer)
An architecture that defines a set of methods to access provided web services with the goal of creating accessiblity for multiple applications.
API (Application Programming Interface)
A collection of protocols and tools defining functions and variables that communicate with a database for making a software application.

The REST API is created with CRUD (Create, Read, Update, Delete) operations. The REST API is consumed by making an HTTP request (GET, POST, PUT or DELETE) from the client side. The API is implemented in manner to return a response in JSON, XML, or any other format.


    class Database{
        private $host = 'localhost';
        private $user = 'root';
        private $password = "password";
        private $database = "demo"; 
    
        public function getConnection(){	
            $conn = new mysqli($this->host, $this->user, $this->password, $this->database);
            if($conn->connect_error){
                die("Error failed to connect to MySQL: " . $conn->connect_error);
            } else {
                return $conn;
            }
        }
    }