Setup Laravel Development Environment (MacOS)

Setup Composer

Reference

(1) Download composer setup file

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

(2) Run setup file

php composer-setup.php

(3) Remove setup file

php -r "unlink('composer-setup.php');"

(4) Make composer available globally

mv composer.phar /usr/local/bin/composer

(5) Check version

composer -V


Setup PHPStorm

Reference

(1) Install Laravel plugin. (Preferences | Plugins | Laravel)

(2) Install IDE Helper.

composer require barryvdh/laravel-ide-helper:v2.6.6 -n --no-progress

(3) Enable laravel ide helper as providers. (configs/app.php)

'providers' => [
  // Laravel IDE helper
  'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider',

]

(4) Reload PHPStorm.


Setup Development Server

(1) Add PHP Script (Runs | Edit Configuration | Add New)

(2) Select "artisan" in your project folder and set "serve" as arguments.


(3) This runs artisan serve on localhost port 8000. To run it on a different port, set " --port=xxxx" in the arguments after "serve".


AI Summary
Chrome On-device AI 2024-12-06 18:39:04

Share Article