Skip to content

Instantly share code, notes, and snippets.

@ahmetburakbabursah
Created December 10, 2022 21:00
Show Gist options
  • Save ahmetburakbabursah/c31486855a6a295b60726d1e20489fe0 to your computer and use it in GitHub Desktop.
Save ahmetburakbabursah/c31486855a6a295b60726d1e20489fe0 to your computer and use it in GitHub Desktop.
Get you to install Laravel/Valet on your Mac. (Apple Silicon)

Laravel valet installation on Mac (Apple Silicon)

Released on December 10, 2022 and is up to date.

This will get you to install Laravel/Valet on your Mac with Apple Silicon.

Homebrew

Check from https://brew.sh site in case the command is up to date.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Once the installation is complete, enter the following command:

echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> ~/.zshrc
source ~/.zshrc

Check that brew is configured correctly with the command: brew --version

PHP & MySQL

This command will install the latest version unless we specify a version.

brew install php
brew install mysql

Composer

Composer installation command will change with every version.

Check from https://getcomposer.org/download/ site in case the command is up to date.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Once the installation is complete, enter the following command:

sudo mv ~/composer.phar /usr/local/bin/composer
export PATH="$PATH:$HOME/.composer/vendor/bin"

Check that composer is configured correctly with the command: composer --version

Laravel

This command will install the latest version of Laravel.

composer global require "laravel/installer"

Check that laravel is configured correctly with the command: laravel --version

Valet

Check from https://laravel.com/docs/9.x/valet site.

This command will install the latest version of Laravel Valet.

composer global require laravel/valet
valet install

Check that valet is configured correctly with the command: valet --version

Create Project

That's was all! Everything ready.

Now let's go from the terminal to the path where we will host our projects. You can specify the path you want.

cd Documents/Projects/Laravel

We must inform the valet that we will host our Laravel applications under this directory. The following command will do this:

valet park

You should enter the name of your app instead of burak.

laravel new burak

Our application has been created in cd Documents/Projects/Laravel/burak directory. Go to project directory:

cd burak

The application is linked to valet with the link command.

valet link

To view a list of your linked directories, you may run the following command:

valet links

Additionally, you may unlink an app from valet with the command, if current path is the application directory:

valet unlink

else, you may also uninstall it by enter the app name.

valet unlink burak

In most cases you should specify the application url in the file below.

sudo nano /etc/hosts

Enter your app url into the file. eg:

127.0.0.1       burak.test

Finally, we may enter the following command to add TLS certificate to our app:

valet secure burak

We can now access our site at burak.test

You may use the following command to rename the TLD:

valet tld dev

That's all there is to it.

Screenshot 2022-12-10 at 23 41 22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment