如何从 phar 文件安装 Laravel?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21770568/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 09:02:18  来源:igfitidea点击:

How do I install Laravel from phar file?

phplaravelinstallationlaravel-4phar

提问by systemovich

I downloaded the laravel.pharfile, renamed it to laravel, moved it to /usr/local/bin, then made it executable by all.

我下载了laravel.phar文件,将它重命名为laravel,将它移动到/usr/local/bin,然后让它被所有人执行。

In my home directory, I tried laravel new sandbox, but nothing happens.

在我的主目录中,我尝试了laravel new sandbox,但没有任何反应。

What did I do wrong?

我做错了什么?

Thanks.

谢谢。

回答by systemovich

Do not bother renaming the file, and do not bother with /usr/local/bin. Just place laravel.phar in the folder where you are going to use it.

不要打扰重命名文件,也不要打扰/usr/local/bin。只需将 laravel.phar 放在您要使用它的文件夹中。

Then make sure you have the PHP curl module installed. On OpenSuse:

然后确保您安装了 PHP curl 模块。在 OpenSuse 上:

sudo zypper install php5-curl

Then create your new Laravel application with the following command (notice you use the php command to execute the .phar file):

然后使用以下命令创建新的 Laravel 应用程序(注意您使用 php 命令来执行 .phar 文件):

php laravel.phar new <project-name> 

e.g. php laravel.phar new sandbox. A new subfolder will be created with the project-name as its name, containing the skeleton of a Laravel application.

例如php laravel.phar new sandbox。将创建一个以 project-name 为名称的新子文件夹,其中包含 Laravel 应用程序的框架。

回答by fabian

Or just run:

或者只是运行:

curl -O http://laravel.com/laravel.phar && chmod +x laravel.phar && mv laravel.phar /usr/local/bin/laravel

回答by Christopher Kikoti

This method worked for me.

这种方法对我有用。

  1. Create batch script and name it laravel.bat
  2. Paste the following codes in your laravel.bat file
  1. 创建批处理脚本并将其命名为 laravel.bat
  2. 将以下代码粘贴到您的 laravel.bat 文件中

@ECHO OFF

php "%~dp0laravel.phar" %*

@ECHO 关闭

php "%~dp0laravel.phar" %*

3.Store the laravel.bat file in the same directory as the downloaded PHAR file (laravel.phar)

3.将laravel.bat文件存放在与下载的PHAR文件(laravel.phar)相同的目录下

4.Include the directory path in your environmental variables.

4.在您的环境变量中包含目录路径。

Then you are good to go.... just launch CMD and test it by typing laravel then hit return

然后你就可以开始了......只需启动 CMD 并通过输入 laravel 来测试它然后按回车