$ sudo port install wget tmux php71 php71-openssl php71-mcrypt php71-mbstring
$ sudo port select php php71
$ cd ~
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
$ php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
$ php composer-setup.php
$ php -r "unlink('composer-setup.php');"
建立專案:
$ time php ~/composer.phar create-project --prefer-dist laravel/laravel my-project
運行:
$ php artisan serve
Laravel development server started: <http://127.0.0.1:8000>
收工。
若有碰到奇怪的問題,通常是 php 版本問題:
Parse error: parse error, expecting `'&'' or `"variable (T_VARIABLE)"' in /Users/id/my-project/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 478
Script php artisan optimize handling the post-update-cmd event returned with error code 255
這是因為一開始偷懶不改變 php 環境變數,例如只用 alias php=php71 或是都用 php71 ~/composer.phar create-project --prefer-dist laravel/laravel my-project 這種執行方式所產生出來的,最後還是靠設定 PATH 或是 port select php php71 來解。
沒有留言:
張貼留言