Skip to content

LuisMiSanVe/CSharpPHP_API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

See in spanish/Ver en español

🌐 C# - PHP REST APIs Communication Project

image image image image image image image image image

This project consists in two REST APIs communicating in order to make more distance between the user and the database.

Warning

Part of the code, especially variable names or table columns, are written in Spanish. Thankfully, they're almost the same as their English equivalents.

📋 Prerequisites

First of all, you'll need servers to locate the REST APIs, you can manage to make it work perfectly with XAMPP or similar programs that provide local servers, so make sure you have it installed.

Note

I'll use XAMPP to explain the project's functionality.

Once XAMPP is installed, copy the whole PHPProject folder and paste it into the 'htdocs' folder inside the XAMPP install route. In Windows should be something like C:\xampp\htdocs

Now rise the Apache and MySQL servers in XAMPP and click 'Admin' on the MySQL section and it will open your default browser with PhpMyAdmin, the web-based database manager.

Create a new database called 'phprest' and run the following SQL command to create the main table:

CREATE TABLE `bas_categoria` (
  `id_categoria` int(11) NOT NULL AUTO_INCREMENT,
  `descripcion` varchar(100) DEFAULT NULL,
  `estatus` varchar(15) DEFAULT NULL,
  PRIMARY KEY(`id_categoria`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Now you just need to run CategoriesApi to use the PHP REST API from the C# REST API.

📂 Files

PHP side:

If we could make a timeline of the execution time it would be like this:

  1. 'index' starts executing the code.
  2. 'database' takes the connection parameters from 'definiciones' and connects to the database server.
  3. From the C# REST API we try an endpoint.
  4. 'index' calls 'bas_categoria_controller' to execute the order.
  5. 'bas_categoria_controller' calls 'bas_categoria' and executes the code.
  6. 'index' returns the result.
  7. The C# REST API receives it and shows it to the user.

💻 Technologies used