-->

2022年6月7日 星期二

macOS 建立laravel專案

 先安裝brew

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

因為安裝的時候路徑沒安裝好,所以要額外設定

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/jiangyuchun/.zprofile

eval "$(/opt/homebrew/bin/brew shellenv)"


經brew 裝php

brew install php@8.0

如果要在當下目錄run,要把設定寫到.zhrc

echo 'export PATH="/opt/homebrew/opt/php@8.0/bin:$PATH"' >> ~/.zshrc

echo 'export PATH="/opt/homebrew/opt/php@8.0/sbin:$PATH"' >> ~/.zshrc

For compilers to find php@8.0 you may need to set:

export LDFLAGS="-L/opt/homebrew/opt/php@8.0/lib"

export CPPFLAGS="-I/opt/homebrew/opt/php@8.0/include"

看php版本

php -v    //PHP 8.0.19


經brew裝composer

brew install composer

把composer 的指令簡化

export PATH="$PATH:$HOME/.composer/vendor/bin"


用composer 來安裝Laravel

composer global require laravel/installer


brew安裝node.js

brew install node    //Laravel 前端部分是需要nodejs的


建立一個Laravel項目試試

cd ~/php

composer create-project laravel/laravel test_0608

嘗試啟動

cd test01

php artisan serve

瀏覽 http://127.0.0.1:8000


參考網站

https://adminhk.com/laravel%E6%95%99%E5%AD%B8%E7%AD%86%E8%A8%98-01-laravel8-%E5%85%A5%E9%96%80%E5%8F%8A%E7%92%B0%E5%A2%83%E5%AE%89%E8%A3%9D/

沒有留言:

張貼留言