Skip to content

Configurer l'environnement Windows

Pré-requis

VSCode

Installez Visual Studio Code depuis le site Internet officiel.

Dans la fenêtre de setup cochez la case pour ajouter VS Code à PATH.

PHP

Ouvrez Windows Powershell et saisissez la commande suivante:

Terminal window
Invoke-WebRequest -Uri "https://windows.php.net/downloads/releases/php-8.3.1-nts-Win32-vs16-x64.zip" -OutFile "$env:TEMP\php.zip"; Expand-Archive -Path "$env:TEMP\php.zip" -DestinationPath "C:\php" -Force; $phpIniPath = "C:\php\php.ini"; Copy-Item "C:\php\php.ini-production" $phpIniPath; $extensions = @("ctype", "curl", "xml", "mbstring", "tokenizer", "mysqlnd", "zip", "intl"); foreach ($ext in $extensions) { Add-Content -Path $phpIniPath -Value "extension=$ext"; }; [Environment]::SetEnvironmentVariable("Path", [Environment]::GetEnvironmentVariable("Path", "Machine") + ";C:\php", "Machine"); Remove-Item "$env:TEMP\php.zip" -Force; Write-Host "Configuration de PHP et des extensions terminee. Redemarrez votre systeme."

Redémarrez l’ordinateur.

Pour vérifier la version de php et les extensions, ouvrez l’invite de commande et exécutez les commandes suivantes:

Terminal window
php -v
php -m

Outils de travail

Composer

Ouvrez Windows Powershell et saisissez la commande suivante:

Terminal window
Invoke-WebRequest -Uri "https://getcomposer.org/Composer-Setup.exe" -OutFile "$env:TEMP\Composer-Setup.exe"; Start-Process -FilePath "$env:TEMP\Composer-Setup.exe" -Wait; Remove-Item "$env:TEMP\Composer-Setup.exe" -Force

Une fois le setup lancé, sélectionnez le chemin vers php.exe (C:\php\php.exe), et suivez les autres instructions.

Vous pouvez ensuite vérifier l’installation avec cette commande:

Terminal window
composer -V

Cela devrait afficher la version de Composer installée, confirmant que l’installation a réussi.

Laravel

Pour créer un projet Laravel, saisissez la commande suivante dans le terminal intégré de VSCode (remplacez example-app par le nom de votre projet):

Terminal window
composer create-project laravel/laravel example-app
cd example-app

Une fois le projet créé, naviguez dans le dossier du projet puis démarrez le serveur de développement local de Laravel:

Terminal window
cd example-app
php artisan serve

Une fois que vous aurez démarré le serveur de développement Artisan, votre application sera accessible dans votre navigateur web à l’adresse http://localhost:8000.