GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - navnit-elastic/MVC-REST-API-PHP: Simple MVC REST API framework using PHP and MySQL

BranchesTags
Open more actions menu

Latest commit

 

History

4 Commits
4 Commits

Folders and files

NameName
Last commit message
Last commit date
app
app
 
 
public
public
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

Using PHP MVC REST API

Representational state transfer (REST) is a software architectural that seperates models, views and controller component and interconnectes them. it is a client-server architecture.

Project Overview

This project is created for getting simple knowledge of php with MVC framework.

Project includes PHP as a backend language and MySql database.

Project includes email Authentication and CRUD operation on different records.

Connecting to MySql using PHP

class Model {
    protected $connection = "";
    protected $servername="localhost";
    protected $username="root";
    protected $password=""; // your mysql database password
    protected $dbname=""; // database name

    // connecting with database
    function __construct() {
        mysqli_report(MYSQLI_REPORT_STRICT);
        try {
            $this->connection = new mysqli($this->servername, $this->username, $this->password, $this->dbname);
        } catch(Exception $e) {
            echo "Connection to database is failed".$e->getMessage();
            exit;
        }
    }
}

Calling Model components from Controller

require_once('Models/Model.php');
session_start();

class Controller extends Model {
    function __construct() {
            parent::__construct();
            $baseDir = basename(__FILE__); 
            $location = substr($_SERVER['PHP_SELF'], strpos($_SERVER['PHP_SELF'], $baseDir) + strlen($baseDir));
            if($location) {
                switch($location) {
                    // cases ..
                }
            }
    }
}

About

Simple MVC REST API framework using PHP and MySQL

Topics

apiapi-restbootstrapclient-server-architectureframeworkmvc-architecturemvc-php-frameworkmysqlphp

Resources

Readme
MIT license
Activity

Stars

5 stars

Watchers

1 watching

Forks

0 forks
Report repository

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.