如何在 Windows 上通过 Laravel 安装程序安装 Laravel?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26451187/
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
How to install Laravel via Laravel Installer on Windows?
提问by Markus Hofmann
I'm trying to install the Laravel Framework on Windows with the Laravel Installer method.
我正在尝试使用 Laravel 安装程序方法在 Windows 上安装 Laravel 框架。
In the documentationI found the following:
在文档中,我发现了以下内容:
First, download the Laravel installer using Composer. Make sure to place the “~/.composer/vendor/bin” directory in your PATH so the laravel executable is found when you run the laravel command in your terminal.
首先,使用 Composer 下载 Laravel 安装程序。确保将“~/.composer/vendor/bin”目录放在 PATH 中,以便在终端中运行 laravel 命令时找到 laravel 可执行文件。
Now this PATH does not look familiar to me. Could you tell me the working path for Windows?
现在这个 PATH 对我来说并不熟悉。你能告诉我 Windows 的工作路径吗?
BTW: I'm using WAMP. Composer is installed and updated.
顺便说一句:我正在使用 WAMP。Composer 已安装并更新。
回答by Markus Hofmann
The PATH for Windows:
Windows 的 PATH:
I've found the location where composer stores the Vendor files.
我找到了 composer 存储供应商文件的位置。
So instead of ~/.composer/vendor/bin
, on Windows the following path should be used:
因此~/.composer/vendor/bin
,在 Windows 上,应使用以下路径而不是:
C:\Users\<COMPUTER NAME>\AppData\Roaming\Composer\vendor\bin
How to install the Laravel Installer:
如何安装 Laravel 安装程序:
I assume you have php and composer in your PATH already.
我假设您的 PATH 中已经有 php 和 composer 。
First of all install the Laravel Installer.Open a command prompt and enter:
首先安装 Laravel 安装程序。打开命令提示符并输入:
composer global require "laravel/installer=~1.1"
Then update the PATH environment variablevia e.g. command prompt with admin privileges:
然后通过例如具有管理员权限的命令提示符更新 PATH 环境变量:
setx /M path "%path%;%appdata%\Composer\vendor\bin"
%appdata% is added, so you don't have to worry about adding your computer name.
添加了 %appdata% ,因此您不必担心添加计算机名称。
How to create a fresh Laravel Installation:
如何创建一个全新的 Laravel 安装:
Now you should be able to run laravel commands in the command prompt.
现在你应该可以在命令提示符下运行 laravel 命令了。
To create a fresh laravel installation, open a command prompt in the directory of choice and enter:
要创建全新的 Laravel 安装,请在所选目录中打开命令提示符并输入:
laravel new name_of_directory
If everything went right, you should see the following message:
如果一切顺利,您应该会看到以下消息:
Crafting application...
Application ready! Build something amazing.
制作应用程序...
应用程序准备就绪!建造一些惊人的东西。
回答by Iapilgrim
Use Laragon (http://laragon.org/)
使用 Laragon ( http://laragon.org/)
Install Laragon.
安装拉贡。
Use Laragon Menu to create project
使用 Laragon Menu 创建项目
Take you 5 minutes to have Laravel4 o Laravel5.
带你5分钟拥有Laravel4 o Laravel5。
Launch Laragon Project
启动 Laragon 项目
Laragon automatically create Virtual host for your project name ( project_name.me)
Laragon 自动为您的项目名称创建虚拟主机 (project_name.me)
Hope it helps.
希望能帮助到你。
Source: https://innopy.wordpress.com/2015/02/07/laravel-windows/
来源:https: //innopy.wordpress.com/2015/02/07/laravel-windows/
回答by Placid
If you are having trouble using the command prompt, use the GUI approach:
如果您在使用命令提示符时遇到问题,请使用 GUI 方法:
The path in Windows is:
Windows中的路径是:
C:\Users\UserName\AppData\Roaming\Composer\vendor\bin
C:\Users\UserName\AppData\Roaming\Composer\vendor\bin
In the above path "UserName" is your user name that you are logged in your computer as. If you don't know your username, go here: http://library.queensu.ca/libguides/computers/windows-username-check.htm
在上面的路径中,“UserName”是您登录计算机时使用的用户名。如果您不知道您的用户名,请访问:http: //library.queensu.ca/libguides/computers/windows-username-check.htm
Copy the above path, replace the "UserName" with your username.
复制上面的路径,用你的用户名替换“UserName”。
Then go to your computer's environment variables. Here's how:
然后转到您计算机的环境变量。就是这样:
- Right click on your Computer and go to properties
- Go to Advanced system settings
- Under Advanced Tab, Click on Environment Variables
- 右键单击您的计算机并转到属性
- 进入高级系统设置
- 在高级选项卡下,单击环境变量
Under User Variables
, select Path
and click Edit
:
在 下User Variables
,选择Path
并单击Edit
:
Put a semicolon at the end of the existing text and paste your path, example:C:\ProgramData\ComposerSetup\bin
. Press OK ...
在现有文本的末尾放置一个分号并粘贴您的路径,例如:C:\ProgramData\ComposerSetup\bin
. 按确定...
Restart your command prompt and type laravel
and hit enter. If the path was successfully set, you will see "Laravel Installer Version ... "
重新启动命令提示符并键入laravel
并按回车键。如果路径设置成功,你会看到“Laravel Installer Version ...”
回答by Abdul Rahman A Samad
How to install Laravel on Windows using WAMP
如何使用 WAMP 在 Windows 上安装 Laravel
- Install WAMP first.
- 首先安装 WAMP。
I leave everything to default.
我让一切都默认。
- Enable OpenSSL and all required extensions in PHP.ini
- 在 PHP.ini 中启用 OpenSSL 和所有必需的扩展
After you installed WAMP, you need to do this. This is how you make sure OpenSSL is enabled:
安装 WAMP 后,您需要执行此操作。这是确保启用 OpenSSL 的方法:
On your right hand side of your taskbar, click WAMP and then choose PHP.ini.
在任务栏的右侧,单击 WAMP,然后选择 PHP.ini。
And then find php_openssl, and then remove the semicolon in front of php_openssl.
然后找到php_openssl,然后去掉php_openssl前面的分号。
And then, save. Close that file and now go to wamp manager again, and now enable OpenSSL there just to be safe.
然后,保存。关闭该文件,现在再次转到 wamp 管理器,现在启用 OpenSSL 只是为了安全。
After you do that, restart Wamp.
完成后,重新启动 Wamp。
- Install Composer
- 安装作曲家
Go to https://getcomposer.org/and download Windows installer.
转到https://getcomposer.org/并下载 Windows 安装程序。
The setup will ask for your PHP. if you install your WAMP in default setting, it will usually end up in C:\wamp\bin\php\php5.4.12.
设置将询问您的 PHP。如果您在默认设置下安装 WAMP,它通常会在 C:\wamp\bin\php\php5.4.12 中结束。
If your installation is successful, by running composer on command prompt, you will see all kinds of info just by running that command.
如果您的安装成功,通过在命令提示符下运行 composer,您只需运行该命令即可看到各种信息。
If you can see it, that means your Composer installation is complete. Let's move to the next one.
如果您能看到它,则表示您的 Composer 安装已完成。让我们转到下一个。
- Make sure that your htppd.conf includes httpd-vhosts.conf
- 确保您的 htppd.conf 包含 httpd-vhosts.conf
Now let's make sure that your htppd.conf also includes httpd-vhosts.conf. This is beneficial if you want to make a pretty URL just like this one:
现在让我们确保您的 htppd.conf 也包含 httpd-vhosts.conf。如果你想制作一个像这样的漂亮 URL,这很有用:
Instead of writing up localhost/mylaravel, it would be “nicer” to have that pretty URL, right?
与其写下 localhost/mylaravel,拥有那个漂亮的 URL 会“更好”,对吧?
Anyway, let's go on.
不管怎样,让我们继续吧。
Go to C:\wamp\bin\apache\Apache2.4.4\conf and then open up httpd.conf.
转到 C:\wamp\bin\apache\Apache2.4.4\conf 然后打开 httpd.conf。
After that, search for httpd-vhosts.conf and make sure that there is no ‘#' (pound sign) in front of it. Save. After that restart Wamp just to be safe.
之后,搜索 httpd-vhosts.conf 并确保其前面没有“#”(井号)。节省。之后重新启动 Wamp 只是为了安全。
Now let's begin the fun part: installing Laravel.
现在让我们开始有趣的部分:安装 Laravel。
- Install Laravel in specified folder
- 在指定文件夹中安装 Laravel
You usually want to install your Laravel in your www folder. (Obviously!)
您通常希望将 Laravel 安装在您的 www 文件夹中。(明显地!)
So open up your command prompt, and then change directory to your WWW folder inside your wamp. For me it will be: C:\wamp\www
因此,打开命令提示符,然后将目录更改为 wamp 中的 WWW 文件夹。对我来说,它将是:C:\wamp\www
To change directory, just type cd c:\wamp\www
要更改目录,只需键入 cd c:\wamp\www
Basically you are changing folder to your www folder.
基本上,您将文件夹更改为 www 文件夹。
And then, you can install Laravel. Just use this in your command prompt:
然后,您可以安装 Laravel。只需在您的命令提示符中使用它:
composer create-project laravel/laravel your-project-name –prefer-dist
And then hit enter.
然后按回车。
Just wait a while until it is finished downloading and installing.
只需稍等片刻,即可完成下载和安装。
- Enable Laravel installer
- 启用 Laravel 安装程序
If you want to use Laravel Installer, you have to run this command in your command prompt first:
如果你想使用 Laravel 安装程序,你必须首先在命令提示符中运行这个命令:
composer global require "laravel/installer"
Wait until… everything finished.
等到……一切都结束了。
- Create Virtual Host
- 创建虚拟主机
Now let's create your pretty URL. You have to go to C:\wamp\bin\apache\Apache2.4.4\conf\extra and then open up httpd-vhosts.conf.
现在让我们创建您漂亮的 URL。你必须去 C:\wamp\bin\apache\Apache2.4.4\conf\extra 然后打开 httpd-vhosts.conf。
After that, you just need to paste the following and change your laravel folder to appropriate ones.
之后,您只需要粘贴以下内容并将您的 Laravel 文件夹更改为适当的文件夹即可。
<VirtualHost *:80>
DocumentRoot “c:/wamp/www/mylaravel/public”
ServerName laravel.dev
</VirtualHost>
In my case, I used mylaravel for my laravel installation. You have to change it to something else. For server name, you can change it to whatever you want. In my case, I am using laravel.dev. (You don't want to use google.com because if you do, you won't be able to open up Google).
就我而言,我使用 mylaravel 进行 laravel 安装。你必须把它改成别的东西。对于服务器名称,您可以将其更改为您想要的任何名称。就我而言,我使用的是 laravel.dev。(您不想使用 google.com,因为如果您这样做,您将无法打开 Google)。
Obviously, you have to save and then restart your WAMP again.
显然,您必须保存然后再次重新启动 WAMP。
- Update Windows Hosts file
- 更新 Windows 主机文件
After you have changed your virtual host, you need to change your host file.
更改虚拟主机后,您需要更改主机文件。
Go to C:\Windows\System32\drivers\etc and copy hosts and paste it on your Desktop. And click on the host file you have pasted on your Desktop. Open that up using Notepad.
转到 C:\Windows\System32\drivers\etc 并复制主机并将其粘贴到您的桌面上。然后单击您粘贴在桌面上的主机文件。使用记事本打开它。
Put this in that host file:
把它放在那个主机文件中:
127.0.0.1 laravel.dev
Change laravel.dev into what you already decided in your virtual host file. For me, mine will be laravel.dev.
将 laravel.dev 更改为您在虚拟主机文件中已经确定的内容。对我来说,我的将是 laravel.dev。
Copy the one that you modified just now and put it back into your C:\Windows\System32\drivers\etc folder.
复制刚才修改的那个,放回 C:\Windows\System32\drivers\etc 文件夹。
You're done!
你完成了!
Modified from this source: http://copygrammer.com/how-to-install-laravel-on-windows/(my blog)
从这个来源修改:http: //copygrammer.com/how-to-install-laravel-on-windows/(我的博客)
回答by Misterk
Installing Laravel frameworkon window via Laravel installer:
通过Laravel 安装程序在窗口上安装Laravel 框架:
- make sure you have composeron your computer.
- download the Laravel installerusing Composerby typing following code in the command prompt:
- 确保您的计算机上有作曲家。
- 通过在命令提示符中键入以下代码,使用Composer下载Laravel 安装程序:
composer global require "laravel/installer=~1.1"
作曲家全局需要“laravel/installer=~1.1”
- go to folder:
- 转到文件夹:
C:\Users\ {User Name} \AppData\Roaming\Composer\vendor
C:\Users\ {用户名} \AppData\Roaming\Composer\vendor
copy the vendorfolder and paste it into the folder (Destination folder) where you want to install Laravel project; for example, in folder D:\Test\Laravel.
after pasting, your folder structure look like this: D:\Test\Laravel\vendor
pressing down on Shift key and Right click on the folder vendor in your destination folder (D:\Test\Laravel\vendor), and choose "open command window here".
enter the command below:
laravel new your_project_destination
after the command runs, you will see laravel folder in your_project_destination
复制vendor文件夹并粘贴到你要安装Laravel项目的文件夹(Destination文件夹)中;例如,在文件夹 D:\Test\Laravel 中。
粘贴后,您的文件夹结构如下所示:D:\Test\Laravel\vendor
按住 Shift 键并右键单击目标文件夹 (D:\Test\Laravel\vendor) 中的文件夹供应商,然后选择“在此处打开命令窗口”。
输入以下命令:
laravel 新建 your_project_destination
命令运行后,您将在 your_project_destination 中看到 laravel 文件夹
回答by Joel Fernandes
You can install laravel using Homestead box.
你可以使用 Homestead box 安装 laravel。
There are a few steps you need to follow.
您需要遵循几个步骤。
Make sure that you have windows virtualization turned ON in your BIOS. This will save you a few hours if you are installing it for the first time.
确保在 BIOS 中打开了 Windows 虚拟化。如果您是第一次安装,这将为您节省几个小时。
You will also need to install Vagrant and Virtual Box before starting the installation of Homestead.
在开始安装 Homestead 之前,您还需要安装 Vagrant 和 Virtual Box。
The main advantages of using Homestead is that it provides a Linux virtual machine where you can easily install packages. It does comes with a lot of packages installed.
使用 Homestead 的主要优点是它提供了一个 Linux 虚拟机,您可以在其中轻松安装软件包。它确实安装了很多软件包。
http://deepdivetuts.com/installing-laravel-5-4-on-windows-machine-using-homestead
http://deepdivetuts.com/installing-laravel-5-4-on-windows-machine-using-homestead
回答by Pankaj Gautam
If you have not installed composer on your system get from here.
You will get this if you have composer on your system installed
如果您尚未在系统上安装 composer 从这里获取。
如果你的系统上安装了 composer 你会得到这个
Installing Laravel
安装 Laravel
Step 1: Installing Laravelglobally.
第 1 步:全局安装Laravel。
Open cmdin Windows and enter this command.
在 Windows 中打开cmd并输入此命令。
composer global require "laravel/installer"
This will download the latest version.
这将下载最新版本。
Check by entering the below command.
通过输入以下命令进行检查。
Step 2: Creating a new Laravel Project
第 2 步:创建一个新的 Laravel 项目
Run the below command in cmd, blog
is the name of my new project.
在cmd 中运行以下命令,blog
是我的新项目的名称。
laravel new projectname
That's it. Now you have your new project folder in the directory you have saved.
就是这样。现在您在保存的目录中有新的项目文件夹。