• Stars
    star
    148
  • Rank 249,983 (Top 5 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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.

<?php

$router->get('/home', 'home@index');

$router->post('/home', 'home@post');

$router->get('/', function() {
    echo 'Welcome ';
});

For getting parameters follow below example:

<?php

$router->get('/:name', function($param) {
    echo 'Welcome ' . $param['name'];
});

For example, when I use this url "yourdomin.com/afgprogrammer" I will get following output.

Welcome afgprogrammer

It's just a Piece of cake :)

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:

<?php

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;
    }
}

More Repositories

1

Flutter-examples

Flutter widget example.
Dart
478
star
2

Flutter-Complete-e-commerce

Flutter e-commerce Application design and Animation - day 16-17
Dart
459
star
3

Flutter-Login-Page-UI

Flutter Beautiful Login Page design and Animation - day 12
Dart
400
star
4

Flutter-Shoes-Shop-App

Flutter Shoes Shop Application Design and Animation - day 15
Dart
338
star
5

Flutter-Splash-Screen-Animation

Flutter Splash Screen design and Animation - day 8
Dart
335
star
6

Flutter-food-delivery-app-ui

Flutter Food Delivery Application design and Animation - day 3
Dart
309
star
7

Flutter-home-service-app

Flutter Home Service Application Example - Day 35
Dart
258
star
8

Flutter-GridView-Example-UI

Flutter GridView Example in a Shopping List Design - day 10
Dart
257
star
9

flutter-inspiration-app-ui

Flutter Inspiration Application Design - day 1
Dart
233
star
10

Flutter-Login-Page-3

Flutter Beautiful Login Page Design and Animation - day 14
Dart
230
star
11

Flutter-Login-Page-Design

Flutter Beautiful Login Page Design and Animation - day 13
Dart
229
star
12

Flutter-Login-Signup-page

Flutter Login and Signup Page design and Animation - day 23
Dart
227
star
13

Flutter-Facebook-Redesign

Flutter Facebook Redesign Application Design and Animation - day 19
Dart
196
star
14

Flutter-ecommerce-app-with-getx

Flutter e-commerce app example with GetX - day 59
Dart
195
star
15

Flutter-e-commerce-app-example

Flutter e-commerce Application Example - Day 34
Dart
194
star
16

Flutter-wallet-app

Flutter Wallet Application Example - Day 40
Dart
122
star
17

Flutter-github-application

Flutter Github Following Application, Using Flutter Provider and Flutter HTTP to get data from Github API. - Day 25
Dart
120
star
18

Flutter-Photography-Application

Flutter Photography Application Design and Animation - day 22
Dart
119
star
19

flutter_expense_manager

Flutter Provider and Shared Preferences Sample Application.
Dart
110
star
20

Flutter-google-map-example

Flutter Google Map Example - Day 41
Dart
104
star
21

Flutter-trip-app-ui

Flutter Trip Application UI/UX Design - day 2
Dart
98
star
22

Flutter-simple-chat-app

Simple chat app UI design in Flutter - Day 61.
Dart
87
star
23

Flutter-App-Intro-With-Indicator

Flutter App Intro Application Design and Animation - day 21
Dart
70
star
24

Flutter-Party-Event-Application

Flutter Party Event Application Ui Design, UI/UX design - day 9 Flutter Animation and UI Design.
Dart
70
star
25

Flutter-job-list-application

Flutter Job List Application UI - Day 31
Dart
69
star
26

Flutter-searchable-listview

Flutter Searchable ListView - Day 28
Dart
65
star
27

Flutter-actors-profile-app-ui

Flutter Actors Profile Application UI/UX Design - Day 4
Dart
62
star
28

Flutter-Socks-Shop

Flutter Socks Shop Application Design and Animation - day 20
Dart
60
star
29

Flutter-Travel-Application

Flutter Simple Travel Application Design - day 11
Dart
58
star
30

Flutter-Custom-Carousel

Flutter Custom Carousel Application Design and Animation - day 18
Dart
57
star
31

Flutter-page-transition-animation

Flutter Page-Transition Animation, UI/UX design - day 6
Dart
52
star
32

Flutter-login-page

Flutter dark/light mode Login Page UI design - day 24
Dart
48
star
33

Flutter-button-animation

Flutter Download Bar Button Animation, UI/UX design - day 7 Flutter Animation and UI Design.
JavaScript
43
star
34

Flutter-file-select-upload

Flutter File Select and Upload to the Server with Progress Bar - Day 44
Dart
36
star
35

Flutter-password-validation

Flutter password validation example - Day 29
Dart
35
star
36

Flutter-portfolio-app-concept

Flutter Portfolio App Concept - Day 33
Dart
34
star
37

Flutter-ripple-map-application

Flutter Ripple Animation in a Map Application UI/UX design - day 5
Dart
33
star
38

PHP-MVC-book-library

book library rest-api in PHP MVC
PHP
30
star
39

afgprogrammer

17
star
40

Flutter-event-schedule-app

A Flutter event schedule app example
Dart
17
star
41

afgprogrammer.github.io

My personal blog with NuxtJs
Vue
17
star
42

Task-Template

A task management template design with HTML and CSS
HTML
16
star
43

100-days-of-code-flutter

Here you can find my Flutter 100 Days of Code.
16
star
44

Flutter-instagram-notification-page-ui

Flutter Instagram Notification Page UI - Day 32
Dart
14
star
45

Flutter-instagram-following-list

Let's Redesign Instagram Following List with ListView widget - Day 26/27
Dart
12
star
46

flutter_accounting

An accounting application in flutter for your bank cards
Dart
12
star
47

Opencv-face-detection-python

Face Recognition Ai Project
Python
11
star
48

vue-login-redirect

Redirect after show alert dialog in vue.
Vue
9
star
49

AI-doz-a-star-algorithm

Ai Project with algorithm A Star (A*)
JavaScript
7
star
50

personal-blog

personal blog
HTML
7
star
51

simple-loader-html-css

Simple loader html5 and css3
CSS
7
star
52

CRUD-vue

Vue
7
star
53

picture-template

picture template
HTML
6
star
54

chrome-unsplash-statistic

A Google chrome extension that shows your Unsplash statistic right on your browser's new tab.
Vue
6
star
55

simple-chat-bot

Simple Chat Bot
JavaScript
6
star
56

rock-paper-scissors

rock paper scissors game
HTML
6
star
57

LocalStorage-CRUD

CSS
6
star
58

laravel-dashboard

A starter laravel dashboard
PHP
5
star
59

vue-dashboard

A beautiful dashboard for vue and laravel
JavaScript
3
star
60

vue-skeleton-placeholder

A small CSS library to help you build skeleton placeholders with Vue
2
star
61

file-management-python

A file manager in python script
2
star