php 如何在 wampserver 中正确设置 Laravel 框架?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20984148/
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-08-25 03:43:45  来源:igfitidea点击:

How to setup laravel framework in wampserver properly?

phplaravel

提问by Jerielle

I am studying laravel now. But I am having a difficulty in installing the framework in my wampserver. I followed this instruction but I am getting an error.

我现在正在学习laravel。但是我在 wampserver 中安装框架时遇到了困难。我按照此说明进行操作,但出现错误。

Via Download

通过下载

Once Composer is installed, download the latest version of the Laravel framework and extract its contents into a directory on your server. Next, in the root of your Laravel application, run the php composer.phar install (or composer install) command to install all of the framework's dependencies. This process requires Git to be installed on the server to successfully complete the installation.

安装 Composer 后,下载最新版本的 Laravel 框架并将其内容解压缩到服务器上的目录中。接下来,在 Laravel 应用程序的根目录中,运行 php composer.phar install(或 composer install)命令来安装框架的所有依赖项。此过程需要在服务器上安装 Git 才能成功完成安装。

If you want to update the Laravel framework, you may issue the php composer.phar update command.

如果你想更新 Laravel 框架,你可以发出 php composer.phar update 命令。

But what I did is I extracted the laravel-master file in my www folder then I also put the composer.phar inside the laravel-master folder.

但是我所做的是将 laravel-master 文件解压缩到 www 文件夹中,然后我还将 composer.phar 放入了 laravel-master 文件夹中。

So I have a directory like this.

所以我有一个这样的目录。

C:/wamp/www/laravel-master/

C:/wamp/www/laravel-master/

Here's my structure

这是我的结构

- wamp
  - www
    - laravel
      - app (folder)
      - boostrap (folder)
      - public (folder)
      - .gitattributes
      - .gitignore
      - artisan
      - composer.json 
      - composer.phar
      - CONTRIBUTING.md
      - phpunit.xml
      - readme.md
      - server.php
      - upgrade.md

And in my command prompy I install the composer.phar by this way:

在我的命令提示符中,我通过这种方式安装 composer.phar:

C:\wamp\www\laravel>php composer.phar install

But here's my error

但这是我的错误

Installing dependencies Your requirements could not be solved to an installable set of packages.

安装依赖项您的要求无法解决为一组可安装的软件包。

Problems:
        - The requested package "laravel/framework" with constraint [> 4.0.9999999.9999999, < 4.1.9999999.9999999] could not be found.
        - Problem caused by:
                - Installation of package "laravel/laravel" with constraint == 1.0.0.0 was requested. Satisfiable by packages [laravel/laravel-1.0.0.0].
                - Package "laravel/laravel-1.0.0.0" contains the rule laravel/laravel requires laravel/framework ([> 4.0.9999999.9999999, < 4.1.9999999.9999999]). No package satisfies this dependency.

I also tried to install it using composer but I have an error too.

我也尝试使用 composer 安装它,但我也有错误。

C:\wamp\www\laravel>composer create-project laravel/laravel --prefer-dist
Installing laravel/laravel (v4.1.0)
  - Installing laravel/laravel (v4.1.0)



  [RuntimeException]
  You must enable the openssl extension to download files via https



create-project [-s|--stability="..."] [--prefer-source] [--prefer-dist] [--repository-url="..."] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--keep-vcs] [--no-install] [package] [directory] [version]

When I checked the ssl in my apache and PHP it is enable. And also I check it using the phpinfo()

当我在 apache 和 PHP 中检查 ssl 时,它已启用。而且我还使用 phpinfo() 检查它

Please help me guys. What should I do?

请帮帮我。我该怎么办?

回答by Ravi Delixan

Installing Laravel 4 on WAMP

在 WAMP 上安装 Laravel 4

1. Enable OpenSSL

1. 启用 OpenSSL

OpenSSL must be enabled in the PHP configuration.

必须在 PHP 配置中启用 OpenSSL。

Edit php.iniin your WAMP's PHP folder, e.g.:

php.ini在 WAMP 的 PHP 文件夹中编辑,例如:

C:\wamp\bin\php\{Your.PHP.Version}\

where {Your.PHP.Version}is something like php5.4.12.

哪里{Your.PHP.Version}有类似的东西php5.4.12

Note:

笔记:

You should not edit the php.iniinside

你不应该编辑php.ini内部

C:\wamp\bin\apache\{Your.Apache.Version}\bin

where {Your.Apache.Version}is something like Apache2.4.4, because that is not the file that Composer uses.

where{Your.Apache.Version}类似于Apache2.4.4,因为那不是 Composer 使用的文件。

Find the following line and remove its preceding semicolon (if there is one) and save the file. So change

找到以下行并删除其前面的分号(如果有)并保存文件。所以改变

;extension=php_openssl.dll

to

extension=php_openssl.dll

2. Install Composer

2. 安装作曲家

Now we need to install Composer. This is a dependency manager that will download the latest release of Laravel and specific versions of Laravel's dependencies, such as Doctrine and Symfony.

现在我们需要安装 Composer。这是一个依赖管理器,它将下载最新版本的 Laravel 和特定版本的 Laravel 依赖项,例如 Doctrine 和 Symfony。

2.1. Download the Composer Windows installer from

2.1. 从以下位置下载 Composer Windows 安装程序

https://getcomposer.org/download/

2.2. Run the installer.

2.2. 运行安装程序。

2.3. When it asks for the location of php.exe, point it to the executable in your WAMP's PHP folder, e.g.:

2.3. 当它询问 的位置时php.exe,将其指向 WAMP 的 PHP 文件夹中的可执行文件,例如:

C:\wamp\bin\php\{Your.PHP.Version}\

2.4. Finish the installation.

2.4. 完成安装。

2.5. Open a command-line interface (cmd) and type:

2.5. 打开命令行界面 (cmd) 并键入:

composer

It should return a list of options. If you get an error, restart your computer and try again.

它应该返回一个选项列表。如果出现错误,请重新启动计算机并重试。

Composer has now been installed and added to your PATH environment variable. This means you can run it from any directory using the command-line interface.

Composer 现已安装并添加到您的 PATH 环境变量中。这意味着您可以使用命令行界面从任何目录运行它。

3.Install Laravel

3.安装Laravel

Now that Composer has been installed, Composer can download and install Laravel on your system.

现在已经安装了 Composer,Composer 可以在您的系统上下载并安装 Laravel。

3.1. Open a command-line interface (cmd).

3.1. 打开命令行界面 (cmd)。

3.2. Go to the directory in which you want to install Laravel. This is usually your development directory. In this tutorial, we'll use C:\wamp\www\laravel

3.2. 转到要安装 Laravel 的目录。这通常是您的开发目录。在本教程中,我们将使用C:\wamp\www\laravel

3.3. Instruct Composer to install Laravel into a project directory. We use project name myproject.

3.3. 指示 Composer 将 Laravel 安装到项目目录中。我们使用项目名称myproject

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

Note:

笔记:

This will install Laravel in a subdirectory named myprojectunder current working directory.

这将myproject在当前工作目录下命名的子目录中安装 Laravel 。

Now your project has a running directory like

现在你的项目有一个运行目录,比如

C:\wamp\www\laravel\myproject\public\

Please check as accepted answer and upvote.

请检查已接受的答案并投票。

回答by Ferrakkem Bhuiyan

I am using this procedure to set up laravel to wamp server and it work perfectly

我正在使用此程序将 laravel 设置为 wamp 服务器,并且运行良好

1.you have to put laravel in  C:\wamp\www folder

2.then u have to go application/config ....open application.php and change url='';

3.change key='K3u4UsHKh7AjSitP9VLTMtbd1mjvdzmQ'

4.then u have to go int C:\wamp\bin\apache\Apache2.2.21\conf\extra  folder then
  open <<=== httpd-vhosts.conf ===>> file and paste below this line into that folder

<VirtualHost *:80>
    DocumentRoot C:/wamp/www/laravel/public
    ServerName xxxxx.dev
</VirtualHost>


5.then go   C:\Windows\System32\drivers\etc  folder and open <<=== hosts ===>> file then paste
 127.0.0.1       xxxxx.dev

6.then go C:\wamp\www\laravel\public folder ...and then open a.htaccess ..then paste 
Options +FollowSymLinks
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php [L]
7.Then u have to go >> C:\wamp\bin\apache\apache2.2.22\conf <<  this directory & open httpd.conf & comment out this line

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

8.then go wamp server .....start it ..and click rewrite mode in apache->apache module..then restart wamp server

9.then go ur browser and write xxxxx.dev/docs  ...

I hope this helps you!

我希望这可以帮助你!

回答by bgallagh3r

You will need to enable openssl and curl in php to run composer properly you must do this in both the apache bin and the php bin in wamp. Apache uses it's own php.ini when WAMP server is running, however anytime you run PHP from the command line it runs using the wamp/bin/php version so edit both these files to ensure it runs properly: /wamp/bin/apache/ApacheX.X.X/bin/php.iniand /wamp/bin/php/phpX.X.X/php.ini

您需要在 php 中启用 openssl 和 curl 才能正确运行 composer 您必须在 apache bin 和 wamp 中的 php bin 中执行此操作。Apache 在 WAMP 服务器运行时使用它自己的 php.ini,但是无论何时您从命令行运行 PHP,它都会使用 wamp/bin/php 版本运行,因此请编辑这两个文件以确保其正常运行: /wamp/bin/apache/ApacheX.X.X/bin/php.ini/wamp/bin/php/phpX.X.X/php.ini

look for extension=php_openssl.dll ~line 970 and extension=php_curl.dll ~line 952

寻找 extension=php_openssl.dll ~line 970 和 extension=php_curl.dll ~line 952

After that is done you should set up a virtualhost by following these steps: http://www.kristengrote.com/blog/articles/how-to-set-up-virtual-hosts-using-wamp

完成后,您应该按照以下步骤设置虚拟主机:http: //www.kristengrote.com/blog/articles/how-to-set-up-virtual-hosts-using-wamp

In new versions of WAMP you can copy the vhosts.conf into the wamp/vhosts dir to create separate vhosts file for each vhost you set up.

在新版本的 WAMP 中,您可以将 vhosts.conf 复制到 wamp/vhosts 目录中,以便为您设置的每个 vhost 创建单独的 vhosts 文件。

Make sure you point the documentroot to your /public dir of where your laravel project will be (it does not need to be in wamp/www it can be installed in wamp/myproject if you want so long as the webroot points to wamp/myproject/public.

确保将 documentroot 指向 Laravel 项目所在的 /public 目录(它不需要在 wamp/www 中,如果你愿意,只要 webroot 指向 wamp/myproject,它可以安装在 wamp/myproject 中/民众。

It's best to download the windows installer and install composer globally. Once it is installed simply use Laravel's quick install method by typing composer create-project laravel/laravel your-project-name --prefer-dist

最好下载 Windows 安装程序并全局安装 Composer。安装完成后,只需键入 Laravel 的快速安装方法composer create-project laravel/laravel your-project-name --prefer-dist

If you are running PHP 5.4 in your wamp stack you can simply use the CLI to go to the root of your laravel install and type php artisan servewhich will fire up PHP's built in webserver on port 8000. You can access your laravel project by going to localhost:8000 or fire up wamp and visit the vhost domain you setup in the steps above.

如果您在 wamp 堆栈中运行 PHP 5.4,您可以简单地使用 CLI 转到 Laravel 安装的根目录并键入php artisan serve这将在端口 8000 上启动 PHP 的内置网络服务器。您可以通过转到 localhost 来访问您的 Laravel 项目: 8000 或启动 wamp 并访问您在上述步骤中设置的虚拟主机域。

If all goes well you should get the "You have arrived!" welcome screen.

如果一切顺利,你应该得到“你到了!” 欢迎画面。