Skip to content

This a basic API with authenticated CRUD operations, receives and outputs JSON, and was developed with PHP, without frameworks.

Notifications You must be signed in to change notification settings

Romanti-Ezer/DrinkWaterAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Drink Water API

About

This a basic API with authenticated CRUD operations, receives and outputs JSON, and was developed with PHP, without frameworks. Some validations were implemented and the returned HTTP responses are based on default on default, like 200 for Ok, 201 for created, 401 for unauthorized, 404 for not found and so on.

How to run in localhost

  • Clone this repository git clone https://github.com/Romanti-Ezer/DrinkWaterAPI.git
  • Create a database
  • Create a table called user. If you change this name, will be necessary to update ````classes/user.php```
CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(191) NOT NULL,
  `name` varchar(191) NOT NULL,
  `password` varchar(191) NOT NULL,
  `drink_counter` int(11) NOT NULL DEFAULT 0,
  `token` varchar(191) NOT NULL,

  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  • Configure the database in config.php
  • Configure a VirtualHost if necessary
<VirtualHost drinkwater.api:80>
    ServerAdmin [email protected]
    DocumentRoot "D:/xampp/htdocs/drinkwaterapi"
    ServerName drinkwater.api
    ServerAlias drinkwater.api
    ErrorLog "logs/drinkwater.api-error.log"
</VirtualHost>
  • Important: keep the .htaccess setting. This file is very important to controll routes.
  • Important²: this API is suposed to run in Apache servers. If necessary to run in Nginx, nginx.conf will need settings.

Testing

I recommend using Postman for testing the endpoints. Using this program, is very easy to set the HTTP method, header, body and create multiple requests.

About

This a basic API with authenticated CRUD operations, receives and outputs JSON, and was developed with PHP, without frameworks.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages