Laravel project
Start a new project
Make a new Laravel project
Method 1: Specific Laravel version using composer create project
- Go to the folder C:\sites_laravel and open Git Bash
- Start a new project where vinyl_shop is the folder of your new project and a specific (major) version of Laravel (for example 5.8) is specified:
composer create-project laravel/laravel="5.8.*" vinyl_shop
WARNING
Always use this first method for making a new Laravel project, as this course is (specifically) written for Laravel version 5.8
The methods below (2 and 3) will make a new project based on the latest Laravel version, which is currently 6.0 (released in September 2019, just when we finished writing this course).
Method 2: Latest Laravel version using composer create-project
- Go to the folder C:\sites_laravel and open Git Bash
- Start a new project where vinyl_shop is the folder of your new project:
composer create-project --prefer-dist laravel/laravel vinyl_shop
Method 3: Latest Laravel version using the Laravel installer
- Go to the folder C:\sites_laravel and open Git Bash
- First, download and install the Laravel installer using Composer:
composer global require laravel/installer
- First, download and install the Laravel installer using Composer:
REMARK
The above command installs the Laravel installer globally, so you only have to do this once
laravel new vinyl_shop
Configure Homestead
- Map the public folder of your new project to your Homestead environment by updating the file C:\vagrant\homestead\Homestead.yaml
sites:
- map: homestead.test
to: /home/vagrant/code
- map: vinyl_shop.test
to: /home/vagrant/code/vinyl_shop/public
1
2
3
4
5
2
3
4
5
- Add the new test domain to your hosts file C:\Windows\System32\drivers\etc\hosts:
192.168.10.10 vinyl_shop.test
- (Re)start Homestead
- If Vagrant is running, stop it with the command
vagrant halt
- Execute the command
vagrant up --provision
- Browse to the project via the URL http://vinyl_shop.test
- If Vagrant is running, stop it with the command
Laravel-ide-helper
- The Laravel 5 IDE Helper Generator package generates a file (_ide_helper.php) that PhpStorm understands, so it can provide accurate autocompletion (for Laravel facades)
- Open a (Git Bash) terminal inside your project folder C:\sites_laravel\vinyl_shop
- Install the package with Composer:
composer require --dev barryvdh/laravel-ide-helper
- (Re)generate the helper file yourself:
php artisan ide-helper:generate
- Generation is based on the files in your project, so the helper file is always up-to-date
- Enable the Laravel plugin in PhpStorm
Source directories
- Enable the Directories in PhpStorm
- If necessary: set app as Sources and prefix it with App\
- Set public as Sources
- Set public as Resource Root
Update an existing project
- To update a project to the latest minor Laravel version (for example the latest version of 5.8.x), use the command
composer update
in a (Git Bash) terminal within the project folder
TIP
To check the version of a Laravel project, open Git Bash inside the project folder and use the command
php artisan --version