2017-06-21 101 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