📚 | 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
This project will be useful throughout the module. Keep it safe!
Do the exercises
-
In a terminal, run the command
php -v
(orphp --version
) to find out the version of your PHP interpreter. -
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.
-
Open the browser to the URL http://localhost:8080/exo1.php
-
Once the command is run and the URL is opened, your terminal should display something similar to:
- Answer the exercises in TD1. Seek help if needed.
The command php -h
(or php --help
) can help you if you are lost with other PHP commands.
- Push the changes
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