在 Windows 7 中安装 Laravel 4.1//使 .phar 文件对 Windows 命令行全局可用 [英] Installing Laravel 4.1 in Windows 7 // Make .phar file globally available to windows command line

查看:25
本文介绍了在 Windows 7 中安装 Laravel 4.1//使 .phar 文件对 Windows 命令行全局可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在通过 Laravel 文档中解释的第一种方法在 Windows 7 中安装 Laravel 4.1 时遇到了一些问题(http://laravel.com/docs/installation#install-laravel).

i have some problems installing Laravel 4.1 in Windows 7 via the first method explained in the Laravel documentation ( http://laravel.com/docs/installation#install-laravel ).

所以我下载了 laravel.phar 文件并将其放在我的路径 ( System32 ) 中.在基于 linux 的系统中,哪个相当于/usr/bin?

So I downloaded the laravel.phar file and put it in my path ( System32 ). Which would be the equivalent of /usr/bin in linux based systems?

(我还在 PATHEXT 系统变量中添加了 .PHAR).

( I also added .PHAR in the PATHEXT system variable ).

当我从命令行运行 laravel 命令时它不知道如何打开它,所以我选择用 php.exe 打开它.现在,当我运行 composer 命令时,它显示:无法打开输入文件:C:Windowssystem32laravel.phar".

When i ran the laravel command from the command line it didn't know how to open it, so i chose to open it with php.exe. Now, when I run the composer command it says: "Could not open input file: C:Windowssystem32laravel.phar".

我想这不是 laravel 本身的问题,而是我对 Windows 命令行的了解有限.通过作曲家安装工作正常.

I suppose it's less a problem with laravel itself but my limited knowledge of the Windows command line. The installation via composer works fine.

感谢任何帮助.

重新表述和澄清这个问题:如何使 .phar 文件对 Windows 命令行全局可用?

To rephrase and clarify this question: How do I make a .phar file globally available to the Windows command line?

推荐答案

Phar 允许您将整个 PHP 应用程序放入 PHP 存档中.它不是您可能认为的直接可执行文件.

Phar allows you to put an entire PHP application into a PHP Archive. It is not a direct executable as you may assume.

要在 Windows 7 上成功安装 Laravel 4.1,你需要 Composer -a 包管理器.首先安装 Composer.这将在您的系统上全局安装.现在可以通过composer"通过命令提示符调用 Composer.

To install Laravel 4.1 successfully on Windows 7, you need Composer -a package manager. First install Composer. This will install globally on your system. Composer can now be called through your command prompt via 'composer'.

接下来,转到您的 WAMP 或 XAMP 项目文件夹所在的位置 - 通常,这将是您的 www 文件夹(即 C:wampwww).

Next, go to where your WAMP or XAMP project folder is -generally, this would be your www folder (i.e. C:wampwww).

新建一个项目目录:www ew_project.现在转到您的开始菜单并以管理员身份运行 cmd.接下来,您需要将目录更改为 C 盘,然后进入 www ew_project 文件夹:

Make a new project directory: www ew_project. Now go to your start menu and run cmd as admin. Next you need to change your directory to the C drive and then into your www ew_project folder:

C:> cd wampwww
ew_project

现在您可以通过调用来利用 composer:

Now you can take advantage of composer by calling:

composer create-project laravel/laravel --prefer-dist

在那个 new_project 文件夹中调用上面的语句,因为那是 laravel 将安装的地方.以上将使您的目录路径为:

Call the above statement in that new_project folder because that is where laravel will install. The above will make your directory path as:

C:wampwww
ew_projectlaravel

Laravel 现在可以在您的系统上使用.您可以通过以下方式验证安装是否成功:

Laravel is now available on your system. You can verify a successful install by going to:

http://localhost/new_project/laravel/public/

基于上述关于使 .phar 全局可用于命令的问题

Based on the above question edit regarding making a .phar globally available for command:

您要查找的目录是C:in -- Linux 上 /usr/bin 的等效文件夹.复制 C:in 文件夹 中的 laravel.phar 文件.或者,您可以将它放在一个文件夹中,例如 C:phplaravel.phar.然后你需要在 PATH 中的某处创建一个名为 laravel.bat 的批处理文件,然后执行以下操作:

The directory your looking for is C:in --the equivalent folder to /usr/bin on Linux. Copy the laravel.phar file in the C:in folder. Or , you can put it in a folder, such as, C:phplaravel.phar. Then you need to make a batch file somewhere within the PATH called laravel.bat which will then do the following:

@ECHO OFF
php "%~dp0laravel.phar" %*

%*"重复传递给 shell 脚本的所有参数.因此,您可以运行laravel 新项目".希望这能为您指明正确的方向.

The "%*" repeats all of the arguments passed to the shell script. Thus, you can run 'laravel new project'. Hope this points you in the right direction.

这篇关于在 Windows 7 中安装 Laravel 4.1//使 .phar 文件对 Windows 命令行全局可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆