Skip to content

Conventions

Conventions are a set of rules that are used to define the structure of code. These rules are used to make the code more readable and easier to understand. Conventions are used in all programming languages. On this page we will discuss the conventions that are used in web development in IoT.

PHP

In the back-end part of your website you are using PHP. PHP has its own conventions.

  • https://www.php-fig.org/psr/psr-12/

For PHP you can use the following tools to help you follow the conventions

  • phpcs: Gives a report (use: phpcs --standard=PSR12 <file or folder>)
  • phpcbf: Fixes errors automatically (use: phpcbf --standard=PSR12 <file or folder>)

Install see PHP_CodeSniffer

HTML and PHP

Make sure that you are not using HTML in your PHP files. You should separate your HTML and PHP. If you need PHP-data, you can make use of Fetch in the frontend and get the data from your API.

Vscode

For help inside Vscode, find a good PHP extension for syntax checking e.g.: PHP Intelephense