Setting up the dev box using Multipass on your machine
- Install Multipass from https://multipass.run
- On Initial run of multipass it will setup the primary box, just let it and close it once it is done
- run
multipass launch -c 2 -d 10G -m 2G -name PHP8.2Laravel -v
to setup ubuntu VM for dev- This will create a VM called
PHP8.2Laravel
with 2GB’s of RAM and 2 CPU Cores as well as 10GB space
- This will create a VM called
- Next we need to open the box with
multipass shell PHP8.2Laravel
in your terminal - Lets do a Quick update and upgrade on the Ubuntu OS in the box :
sudo apt update && sudo apt upgrade -y
- add your SSH keys to
~/.ssh/authorized_keys
-
close the shell in windows PowerShell terminal run
multipass list
- you should see something like this:
PHP8.2Laravel Running 172.29.84.17 Ubuntu 22.04 LTS
Copy the IP address (yours should be different to mine)
Getting VS Code to connect to PHP8.2Laravel VM
- Open VS Code, install the extension “Remote - SSH”
- Once installed press
Ctrl + Shift + P
and typeadd ssh
- this should show you an option to Add new SSH host
- In the prompt you will add the following:
ssh ubuntu@[your IP address from above ]
- Once the setup is complete, click connect in the bottom right hand corner
- follow the prompts to say that you are sshing into a Linux machine etc…
- 🥳 You should now be in the PHP8.2Laravel VM with VS Code
Installing PHP(8.2)
and composer
Please use the VS Code terminal from this step onwards.
We need to add a PPA to install the latest version of PHP as of this post if is 8.3
Install the tools needed to install a PPA:
sudo apt install software-properties-common ca-certificates lsb-release
Add the PPA (this is the Debian maintainers PPA so we can trust it)
LC_ALL=C.UTF-8 sudo add-apt-repository ppa:ondrej/php
Now let us install PHP, common libs, apache2 as well as composer
the PHP package manager sudo apt-get install -y php8.2 php8.2-cli php8.2-common php8.2-mysql php8.2-sqlite3 php8.2-zip php8.2-gd php8.2-mbstring php8.2-curl php8.2-xml php8.2-bcmath composer
After all of this we can run composer-V
and we should see the PHP version as well as the Composer version, the PHP version should be 8.2.xx
If you open a browser and type the boxes IP address you should see an apache2 welcome screen 🥂
Setting up a Laravel(11) project
This is the easy part simply run composer create-project laravel/laravel [your-app-name]
Once that is done in the VS Code terminal type code ./[your-app-name]
and a new window should open with your project in it 👍
VS Code Magic
- Install
PHP Extension Pack
from VS Code extensions this will allow you to have intellisense over your codebase (it will take a few minutes after to index the project) - To run your project type
php artisan serve
into the VS Code terminal and you should see :INFO Server running on [[http://127.0.0.1:8000](http://127.0.0.1:8000/)].
- If you Ctrl Click on the Localhost IP address VS code will port forward :8000 to your local machine form the Ubuntu VM and open it in a web browser for you
Top comments (0)