Skip to main content

📚 | TD 1: First scripts

Clone the project

Clone the project from https://github.com/PHP-BUT2-DACS/TP-TD

git clone https://github.com/PHP-BUT2-DACS/TP-TD.git
warning

This project will be useful throughout the module. Keep it safe!

Do the exercises

  1. In a terminal, run the command php -v (or php --version) to find out the version of your PHP interpreter.

  2. Then, navigate to the project folder /Session 1/TD1. Next, start the PHP server with the following command:

php -S localhost:8080
Understand the command
  • php refers to the PHP interpreter pre-installed on your machine.
  • The -S option (for Server) allows you to create a PHP server. This option requires two parameters:
    • <addr>, which is the address at which we want to use our server (localhost, corresponds to the local host)
    • <port> specifies the port to use for the previously provided address. In computing, it is commonly accepted that ports 808X, 800X, 300X, 500X are reserved for development.
  1. Open the browser to the URL http://localhost:8080/exo1.php

  2. Once the command is run and the URL is opened, your terminal should display something similar to:

🖥️ Output

terminal.png

  1. Answer the exercises in TD1. Seek help if needed.
tip

The command php -h (or php --help) can help you if you are lost with other PHP commands.

  1. Push the changes
warning

Don't forget to push the changes to your GitHub repository

You will need to create a repository in the organization https://github.com/PHP-BUT2-DACS, named TP-TD-<YOUR-NAME>. For example: TP-TD-CAPOSIENA.

You will then need to change the URL of your local clone to the newly created repository. This can be done from the previously cloned TD-TD repository using the following command:

git remote set-url origin https://github.com/PHP-BUT2-DACS/TP-TD-<YOUR-NAME>.git

Next,

  • git add -A
  • git commit -m "my message"
  • git push
X

Graph View