爲Laravel的artisan指令增加bash腳本

#!/bin/bash

if [ -f "./artisan" ]; then
        php artisan "$@"
else
        if [ "$1" == "create" ]; then
                       if [ ! `which git` ]; then 
                                        echo "For this installer to work you'll need to install Git."
                                        echo 'http://gitref.org/'
        fi
                git clone --recursive git://github.com/laravel/laravel.git "./$2"
                cd "$2"; chmod -R 0777 storage/
        else
                echo 'This is not a valid laravel installation so artisan is a bit lost.'
                echo 'http://laravel.com/docs/install#installation'
        fi
fi



保存爲/usr/bin/artisan  並執行 chmod +x /usr/bin/artisan  賦予執行權限
然後,你就可以進入你的項目文件夾,只需輸入bash命令 "artisan create myapp",就會自動從github上clone一份最新的Laravel框架,並會自動設置storage文件夾的權限。之後,你可以直接輸入“ artisan xxxx  xxx”的指令了,而不用輸入'php artisan xxxx xxxx' 。
發佈了41 篇原創文章 · 獲贊 11 · 訪問量 51萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章