Skip to content

Back-end

The HTML, CSS and Javascript are the front-end of your website, there you have the look, feel and the user interaction. But to get the data from your embedded device to your website you need a back-end. The back-end is the part of the website that you cannot see and interact with. The back-end is the server side of your website, it is the part that communicates with the database and the embedded device.

In the start project you will be using a Docker container with PHP installed, but it's up to you to change this later on.

What is PHP?

PHP is a server side scripting language. that is used to develop Static websites or Dynamic websites or Web applications. PHP scripts can only be interpreted on a server that has PHP installed, for you this is already done in your Docker container. To get started you only have to create a '.php'-file in your web folder, and visit this page in your webbrowser.

Hello world!

To get started with PHP, create a file called hello.php in your web folder. In this file you can write your PHP code. To print something to the screen you can use the echo function.

1
2
3
<?php
    echo "Hello world!";
?>

To run this code, visit the page in your webbrowser. You can do this by going to http://localhost/hello.php in your webbrowser. You should see the text Hello world! on your screen.

Tips

You can use PHP to handle your API-requests. You can think of:

  • From PHP you can connect to your own database to store or read data.
    • (Make sure you use mariadb as hostname in your PHP-file to connect to your database!)
  • You can make a HTTP Post request to your PHP-file and read the data from the request by using the $_POST variable.
  • Every request from your API should return a standardized response, you can use JSON for example.