Last active
March 10, 2016 09:18
-
-
Save wastemobile/e24d7afa1f7074ecc646 to your computer and use it in GitHub Desktop.
在 Mac 上搭配 MAMP 使用 PHP Composer and Laravel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 在 Mac 上使用 MAMP, PHP Composer and Laravel | |
在個人目錄 `~/` 下已建立了 `bin` 目錄,並加入執行路徑中。 | |
前往 `bin` 目錄運行下列指令,會安裝一個 `composer.phar` 檔案。(升級時重複運行這行即可。) | |
`curl -sS https://getcomposer.org/installer | php` | |
編輯 `~/.bash_profile` 檔案: | |
``` | |
alias composer='php ~/bin/composer.phar' | |
export PATH="/Applications/MAMP/bin/php/php5.5.10/bin:$PATH" | |
``` | |
ps.升級 MAMP 之後,PHP 版本可能會變動,記得要修改 bash_profile 中的路徑,否則會找不到正確的 PHP 執行檔。 | |
執行 `php -v` 看看版本是否正確;使用 `which php` 確認終端機叫起的 php 確實是 MAMP 目錄下的程式。 | |
## 安裝 Laravel | |
終端機一行指令安裝 Laravel 開發框架。(最新穩定版本:v4.2.0) | |
``` | |
composer create-project laravel/laravel your-project-name --prefer-dist | |
``` | |
安裝以 Laravel 為基礎的 October CMS 也是一行: | |
``` | |
composer create-project october/october project-name dev-master | |
``` | |
## 目前的 bash_profile | |
``` | |
if [ -f ~/.bashrc ]; then | |
source ~/.bashrc | |
fi | |
export PATH=/usr/local/bin:/usr/local/sbin:$PATH:~/bin | |
[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases | |
function git_branch { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return; | |
echo "("${ref#refs/heads/}") "; | |
} | |
function git_since_last_commit { | |
now=`date +%s`; | |
last_commit=$(git log --pretty=format:%at -1 2> /dev/null) || return; | |
seconds_since_last_commit=$((now-last_commit)); | |
minutes_since_last_commit=$((seconds_since_last_commit/60)); | |
hours_since_last_commit=$((minutes_since_last_commit/60)); | |
minutes_since_last_commit=$((minutes_since_last_commit%60)); | |
echo "${hours_since_last_commit}h${minutes_since_last_commit}m "; | |
} | |
PS1="[\[\033[1;32m\]\w\[\033[0m\]] \[\033[0m\]\[\033[1;36m\]\$(git_branch)\[\033[0;33m\]\$(git_since_last_commit)\[\033[0m\]$ " | |
[ -f ~/.git-bash-completion.sh ] && . ~/.git-bash-completion.sh | |
source ~/.nvm/nvm.sh | |
[[ -r $NVM_DIR/bash_completion ]] && . $NVM_DIR/bash_completion | |
alias composer='php ~/bin/composer.phar' | |
export PATH="/Applications/MAMP/bin/php/php5.5.14/bin:$PATH" | |
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment