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

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

问题描述

我在安装Laravel 4.1在Windows 7中有一些问题通过Laravel文档中解释的第一种方法( 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)。这将是相当于/ usr / bin在基于linux的系统?

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?

(我也添加了.PHAR在PATHEXT系统变量)。

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

当我从命令行运行laravel命令,它不知道如何打开它,所以我选择打开它与php.exe。现在,当我运行composer命令,它说:无法打开输入文件:C:\Windows \system32\laravel.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:\Windows\system32\laravel.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 Archive。

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:\wamp \www)。

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

创建一个新的项目目录:www\\\
ew_project。现在转到您的开始菜单,并运行cmd作为管理员。接下来,您需要将您的目录更改为C驱动器,然后进入您的www\\\
ew_project文件夹:

Make a new project directory: www\new_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\new_project folder:

C:\> cd wamp\www\new_project

现在您可以通过调用以下方式利用作曲家:

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:\wamp\www\new_project\laravel\

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:\bin - 等价文件夹 / usr / bin
复制 C:\bin文件夹中的 laravel.phar 文件。或者,您可以将其放在一个文件夹中,例如 C:\php\laravel.phar 。然后,你需要在PATH中的某个地方创建一个批处理文件 laravel.bat ,然后执行以下操作:

The directory your looking for is C:\bin --the equivalent folder to /usr/bin on Linux. Copy the laravel.phar file in the C:\bin folder. Or , you can put it in a folder, such as, C:\php\laravel.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" %*


b $ b

%*重复传递给shell脚本的所有参数。
因此,你可以运行'laravel new project'。希望这能指向正确的方向。

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天全站免登陆