- Saved searches
- Use saved searches to filter your results more quickly
- License
- Navneetchauhannn/MVC-REST-API-PHP
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Saved searches
- Use saved searches to filter your results more quickly
- License
- afgprogrammer/PHP-MVC-REST-API
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Saved searches
- Use saved searches to filter your results more quickly
- License
- dev-bucket/php-mvc-REST-API
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- PHP MVC REST API Save
- Guideline for using PHP MVC REST API
- What is REST API?
- Introduction
- Documentation
- Add a new route
- Database Connection
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
simple MVC REST API framework using PHP and mySql
License
Navneetchauhannn/MVC-REST-API-PHP
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Representational state transfer (REST) is a software architectural that seperates models, views and controller component and interconnectes them. it is a client-server architecture.
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 pl-s">localhost"; protected $username pl-s">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
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A simple PHP MVC REST API framework with PHP 7.2 With routes and some tools to develop your API.
License
afgprogrammer/PHP-MVC-REST-API
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Guideline for using PHP MVC REST API
A REST API (also known as RESTful API) is an application programming interface (API or web API) that conforms to the constraints of REST architectural style and allows for interaction with RESTful web services. REST stands for representational state transfer and was created by computer scientist Roy Fielding.
An API is a set of definitions and protocols for building and integrating application software. It’s sometimes referred to as a contract between an information provider and an information user—establishing the content required from the consumer (the call) and the content required by the producer (the response). For example, the API design for a weather service could specify that the user supply a zip code and that the producer reply with a 2-part answer, the first being the high temperature, and the second being the low.
Simply, the framework will route requests to the correct controller and model. It will do this by analysing request URI for the controller name and the request type (be it POST, PUT, GET, etc.). It will then do some sanity checks, before initialising a new controller and model object and calling the correct method on the controller.
For creating a new route you should open Route.php file from Router directory.
There is already exist some examples in the file which you can use them as you need.
$router->get('/home', 'home@index'); $router->post('/home', 'home@post'); $router->get('/', function() < echo 'Welcome '; >);
For getting parameters follow below example:
$router->get('/:name', function($param) < echo 'Welcome ' . $param['name']; >);
For example, when I use this url «yourdomin.com/afgprogrammer» I will get following output.
If you want to send the POST requests follow below example:
$router->post('/:name', function($param) < echo 'Welcome ' . $param['name']; >);
Consider that for using database you should edit config.php file before start using database.
For getting a database connection, you can use below sample in Model directory:
use MVC\Model; class ModelsHome extends Model < public function getAllUser() < $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "user"); /* $query->row : return 1 row $query->rows : return all rows $query->num_rows : return rows count */ return $query->rows; > >
About
A simple PHP MVC REST API framework with PHP 7.2 With routes and some tools to develop your API.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A simple PHP MVC REST API framework with PHP 7.2 With routes and some tools to develop your API.
License
dev-bucket/php-mvc-REST-API
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Guideline for using PHP MVC REST API
A REST API (also known as RESTful API) is an application programming interface (API or web API) that conforms to the constraints of REST architectural style and allows for interaction with RESTful web services. REST stands for representational state transfer and was created by computer scientist Roy Fielding.
An API is a set of definitions and protocols for building and integrating application software. It’s sometimes referred to as a contract between an information provider and an information user—establishing the content required from the consumer (the call) and the content required by the producer (the response). For example, the API design for a weather service could specify that the user supply a zip code and that the producer reply with a 2-part answer, the first being the high temperature, and the second being the low.
Simply, the framework will route requests to the correct controller and model. It will do this by analysing request URI for the controller name and the request type (be it POST, PUT, GET, etc.). It will then do some sanity checks, before initialising a new controller and model object and calling the correct method on the controller.
For creating a new route you should open Route.php file from Router directory.
There is already exist some examples in the file which you can use them as you need.
$router->get('/home', 'home@index'); $router->post('/home', 'home@post'); $router->get('/', function() < echo 'Welcome '; >);
For getting parameters follow below example:
$router->get('/:name', function($param) < echo 'Welcome ' . $param['name']; >);
For example, when I use this url «yourdomin.com/afgprogrammer» I will get following output.
If you want to send the POST requests follow below example:
$router->post('/:name', function($param) < echo 'Welcome ' . $param['name']; >);
Consider that for using database you should edit config.php file before start using database.
For getting a database connection, you can use below sample in Model directory:
use MVC\Model; class ModelsHome extends Model < public function getAllUser() < $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "user"); /* $query->row : return 1 row $query->rows : return all rows $query->num_rows : return rows count */ return $query->rows; > >
About
A simple PHP MVC REST API framework with PHP 7.2 With routes and some tools to develop your API.
PHP MVC REST API Save
A simple PHP MVC REST API framework with PHP 7.2 With routes and some tools to develop your API.
Guideline for using PHP MVC REST API
What is REST API?
A REST API (also known as RESTful API) is an application programming interface (API or web API) that conforms to the constraints of REST architectural style and allows for interaction with RESTful web services. REST stands for representational state transfer and was created by computer scientist Roy Fielding.
An API is a set of definitions and protocols for building and integrating application software. It’s sometimes referred to as a contract between an information provider and an information user—establishing the content required from the consumer (the call) and the content required by the producer (the response). For example, the API design for a weather service could specify that the user supply a zip code and that the producer reply with a 2-part answer, the first being the high temperature, and the second being the low.
Introduction
Simply, the framework will route requests to the correct controller and model. It will do this by analysing request URI for the controller name and the request type (be it POST, PUT, GET, etc.). It will then do some sanity checks, before initialising a new controller and model object and calling the correct method on the controller.
Documentation
Add a new route
For creating a new route you should open Route.php file from Router directory.
There is already exist some examples in the file which you can use them as you need.
get('/home', '[email protected]'); $router->post('/home', '[email protected]'); $router->get('/', function() < echo 'Welcome '; >);
For getting parameters follow below example:
For example, when I use this url «yourdomin.com/afgprogrammer» I will get following output.
If you want to send the POST requests follow below example:
$router->post('/:name', function($param) < echo 'Welcome ' . $param['name']; >);
Database Connection
Consider that for using database you should edit config.php file before start using database.
For getting a database connection, you can use below sample in Model directory:
db->query("SELECT * FROM " . DB_PREFIX . "user"); /* $query->row : return 1 row $query->rows : return all rows $query->num_rows : return rows count */ return $query->rows; > >
Open Source Agenda is not affiliated with «PHP MVC REST API» Project. README Source: afgprogrammer/PHP-MVC-REST-API