Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A simple PHP MVC REST API framework with PHP 7.2 With routes and some tools to develop your API.

License

NotificationsYou must be signed in to change notification settings

afgprogrammer/PHP-MVC-REST-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is REST API?

If you have been used Facebook, Twitter or any other application in your phone, these applications need to connect to internet for getting and sending data from and to their websites.

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 bellow 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.

wellcome afgprogrammer

It's just a Piece of cake :)

If you want to send the POST requests follow bellow example:

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

Database Connection

Consider that for useing database you should edit config.php file before start useing database.

For getting a database connection, you can use bellow sample in Model directory:

<?phpuseMVC\Model;class ModelsHomeextends Model {publicfunctiongetAllUser() {$query =$this->db->query("SELECT * FROM" .DB_PREFIX ."user");/*          $query->row : return 1 row          $qurty->rows : return all rows          $qurty->num_rows : return rows count        */return$qurty->rows;    }}

Sponsor this project

    Contributors2

    •  
    •  

    Languages


    [8]ページ先頭

    ©2009-2025 Movatter.jp