2017-06-21 102 views
0

我對使用命令行非常新,感到沮喪。我目前正在嘗試安裝laravel以與我的PHP應用程序一起使用。我已經安裝了作曲家,現在我正在嘗試安裝laravel。安裝和運行Laravel

我也第一次嘗試跟隨在documentation的指示laravel中,我有:

  • 安裝作曲家
  • composer global require "laravel/installer"
  • 無法運行laravel new blog-bash: laravel: command not found

接下來我試着遵循laracast video

  • 安裝作曲家
  • composer global require "laravel/installer"
  • 打開的vim的〜/ .bashrc並添加export PATH="$HOME/.composer/vendor/bin:$PATH"
  • 無法運行laravel new blog-bash: laravel: command not found

除了laravel仍然沒有被availiable,當我回到bashrc文件,我得到以下通知:

Found a swap file by the name "~/.bashrc.swp" 
      owned by: Shawn dated: Wed Jun 21 16:01:37 2017 
     file name: ~Shawn/.bashrc 
      modified: YES 
     user name: Shawn host name: Shawns-MBP.domain 
     process ID: 39328 
While opening file "/Users/Shawn/.bashrc" 
      dated: Wed Jun 21 16:19:11 2017 
     NEWER than swap file! 

(1) Another program may be editing the same file. If this is the case, 
    be careful not to end up with two different instances of the same 
    file when making changes. Quit, or continue with caution. 
(2) An edit session for this file crashed. 
    If this is the case, use ":recover" or "vim -r /Users/Shawn/.bashrc" 
    to recover the changes (see ":help recovery"). 
    If you did this already, delete the swap file "/Users/Shawn/.bashrc.swp" 
    to avoid this message. 

,我再次非常受這個過程混亂,根本不能完成我的周圍了什麼錯誤,爲什麼它適用於其他人的頭,但我似乎無法得到laravel正確安裝。

+1

將作曲者路徑添加到.bash_profile中,方法是將現有的作者追加到:不要忘記重新運行它,或者直接登錄並重新登錄 –

+1

或者,您也可以通過在終端中發佈Composer create-project命令來安裝Laravel (https://laravel.com/docs/5.4/installation#installing-laravel): 作曲家創建項目--prefer-dist laravel/laravel博客 – manian

回答

1

你的系統無法找到laravel命令。假設你沒有得到與composer global require "laravel/installer"命令的任何錯誤,安裝程序沒有更新系統的已知路徑(基本上,它需要知道laravel映射到~/.composer/vendor/bin/laravel而現在,事實並非如此)。

修改爲~/.bashrc的目的是解決這個問題,但您需要運行source ~/.bashrc或註銷並重新登錄,以使.bashrc生效。

的替代方法(和我個人比較喜歡的方式)是做什麼@manian在評論中說,並運行composer create-project --prefer-dist laravel/laravel blog。這使您無需安裝和使用Laravel安裝程序即可創建Laravel項目。

至於你對.swp文件的問題,這是不正確退出Vim的結果。如果Vim崩潰,Vim會創建swp文件作爲備份。 When exited properly,它刪除這些備份文件。但是,如果您不正確地退出Vim,則無法刪除它們。如果您的文件已成功更新並保存,請致電then you can simply delete it

+0

謝謝你,'source〜/ .bashrc'解決了這個問題並感謝你也給我另闢蹊徑。 – Shawn31313