dongyunqin7307 2017-06-21 20:23
浏览 45
已采纳

安装和运行Laravel

I am extremely new and frustrated with working with a command line. I am currently trying to install laravel to use with my PHP application. I have installed composer and now I am trying to install laravel.

I have first tried to follow the instructions on the documentation for laravel in that I have:

  • installed composer
  • ran composer global require "laravel/installer"
  • failed to run laravel new blog: -bash: laravel: command not found

Next I tried to follow a laracast video:

  • installed composer
  • ran composer global require "laravel/installer"
  • opened vim ~/.bashrc and added export PATH="$HOME/.composer/vendor/bin:$PATH"
  • failed to run laravel new blog: -bash: laravel: command not found

In addition to laravel still not being availiable, when I go back to the bashrc file, I get the following notice:

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.

Again, I am extremely confused by this process and simply can not wrap my head around what is going wrong and why it works for other people but I can not seem to get laravel correctly installed.

  • 写回答

1条回答 默认 最新

  • doukun1450 2017-06-21 21:09
    关注

    Your system is unable to find the laravel command. Assuming you did not get any errors with the composer global require "laravel/installer" command, the installer didn't update your system's known paths (basically, it needs to know that laravel maps to ~/.composer/vendor/bin/laravel and right now, it doesn't).

    The edit to ~/.bashrc is intended to fix that, but you need to either run source ~/.bashrc or log out and log back in for the change to your .bashrc to take effect.

    The alternative way (and the way I personally prefer) is to do what @manian said in the comments and run composer create-project --prefer-dist laravel/laravel blog. This allows you to create Laravel projects without needing to install and use the Laravel installer.

    As for your issue with the .swp file, that's the result of not exiting Vim properly. Vim creates swp files as a backup in case Vim crashes. When exited properly, it deletes these backup files. However, if you exit Vim improperly, it's unable to delete them. If your file has been successfully updated and saved, then you can simply delete it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#vscode#的问题:ESP32开发板对接MQTT实现小灯泡的开关
  • ¥15 TMC2209串口模式下读取不到寄存器的值串口助手蓝色字体是发过去的消息,绿色字体是收到的消息,第二行发送读取寄存器的指令但是没有读取到寄存器的值串口助手如下图:接线如下图,如何解决?
  • ¥15 高通安卓11提取完整线刷包软件,或者优博讯dt50顺丰刷机包
  • ¥20 C,有个译码器,换了信道就跑不出原来数据
  • ¥15 MIMIC数据库安装问题
  • ¥60 基于JTag协议开发Fpga下载器上位机,哪位大🐂有偿指导?
  • ¥20 全书网Java爬取数据
  • ¥15 怎么获取红包封面的原始链接,并且获取红包封面序列号
  • ¥100 微信小程序跑脚本授权的问题
  • ¥100 房产抖音小程序苹果搜不到安卓可以付费悬赏