php 如何安装 Laravel 5.0

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

How to install Laravel 5.0

phplaravelcomposer-phplaravel-5

提问by Webnet

I'm having trouble getting a test instance of Laravel 5.0 up and running so I can assist with this transition.

我在启动和运行 Laravel 5.0 的测试实例时遇到问题,因此我可以协助完成此转换。

1) Creating a new app from https://github.com/laravel/laravel/tree/developleads to the following error when running composer install.

1) 从https://github.com/laravel/laravel/tree/develop创建一个新的应用程序在运行时会导致以下错误composer install

{"error":
    {"type":"ErrorException",
     "message":"Undefined index: timezone",
     "file":"\/Projects\/indatus\/dispatcher-test-app\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/start.php",
     "line":167}
}
{"error":
    {"type":"ErrorException",
     "message":"Undefined index: timezone",
     "file":"\/Projects\/indatus\/dispatcher-test-app\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/start.php",
     "line":167}}

Am I completely missing something?

我完全错过了什么吗?

UPDATE: This question/answer was only relevant when Laravel 5 was in the development stage. You should now reference the Laravel Documentationfor how to install Laravel

更新:这个问题/答案仅在 Laravel 5 处于开发阶段时才相关。您现在应该参考Laravel 文档了解如何安装 Laravel

回答by Marcin Nabia?ek

As Laravel 5 is already final release, to install it, you should run

由于 Laravel 5 已经是最终版本,要安装它,您应该运行

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

in your console. test-laravel-5-projectis the name of your project you can call it anyway you want - for example myblog, myapp etc. Laravel files will be put inside this directory

在您的控制台中。test-laravel-5-project是您的项目名称,您可以随意调用它 - 例如 myblog、myapp 等。 Laravel 文件将放在此目录中

You can also use alternative method using

您还可以使用替代方法使用

composer global require "laravel/installer=~1.1"

and then running

然后运行

laravel new test-laravel-5-project 

For detailed info you should look at official Laravel installation notes

有关详细信息,您应该查看官方 Laravel 安装说明



The below answer is being kept only for historical reasons and it was valid when Laravel 5 still was in its development stages. You should now only use the method mentioned above

以下答案仅出于历史原因保留,并且在 Laravel 5 仍处于开发阶段时有效。你现在应该只使用上面提到的方法

I've just tested this and there are two ways of installing Laravel 5:

我刚刚对此进行了测试,有两种安装 Laravel 5 的方法:

One-step method

一步法

You just run:

你只需运行:

composer create-project laravel/laravel test-laravel-5-project dev-develop --prefer-dist

and composer will create the whole directory structure. In above command test-laravel-5-projectis your project name - you can of course name it as you want (composer will create directory with this name and put all Laravel5 files inside this directory)

composer 将创建整个目录结构。在上面的命令中test-laravel-5-project是你的项目名称 - 你当然可以随意命名(composer 将使用这个名称创建目录并将所有 Laravel5 文件放在这个目录中)

Multi-step method

多步法

  1. Download https://github.com/laravel/laravel/tree/developwith option Download ZIP
  2. Unpack it in web directory
  3. Run composer update(not composer install) in directory where you unpacked your ZIP file
  1. 使用选项下载https://github.com/laravel/laravel/tree/developDownload ZIP
  2. 解压到web目录
  3. 在解压 ZIP 文件的目录中运行composer update(not composer install)

Using both methods when you run URL for your project in the browser (for example http://localhost/projects/test-laravel-5-project/publicdepending on your webserver settings ) you will get standard Laravel website You have arrived.

在浏览器中为项目运行 URL 时使用这两种方法(例如,http://localhost/projects/test-laravel-5-project/public取决于您的网络服务器设置),您将获得标准的 Laravel 网站You have arrived.

Both methods should work well. Give either one a try, whichever works best for you.

这两种方法都应该很好用。试一试,看哪个最适合你。

回答by Rikin Adhyapak

Go to CLI and enter following command line. make sure composer is already installed.

转到 CLI 并输入以下命令行。确保已经安装了 Composer。

$composer create-project laravel/laravel <yourdirectryname> dev-developIt will ask you a question about removing .git files enter Y then. change the directory to

$composer create-project laravel/laravel <yourdirectryname> dev-develop它会问你一个关于删除 .git 文件的问题,然后输入 Y。将目录更改为

$cd <yourdirectoryname>then enter following command

$cd <yourdirectoryname>然后输入以下命令

$ php artisan -V

$ php 工匠 -V

you will be able to see following message.

您将能够看到以下消息。

Laravel Framework version 5.0-dev means you have installed laravel 5 successfully!

Laravel Framework 5.0-dev 表示你已经成功安装了 Laravel 5!

回答by Vikash

Run this command from where you want to store your project

从要存储项目的位置运行此命令

composer create-project laravel/laravel <projectname>

Remember, it will download the latest version of laravel application from git.

请记住,它将从 git 下载最新版本的 laravel 应用程序。

if you are using linux then give permission to bootstrap/cacheand storageby running the command chmod 777 -R <dir name>from root of your laravel project

如果您使用的是 linux,则通过从 Laravel 项目的根目录运行命令来授予引导/缓存存储权限chmod 777 -R <dir name>

回答by Karthiga

composer global require "laravel/installer=~1.1"

作曲家全局需要“laravel/installer=~1.1”

回答by Hassan Raza

First you need to install laravel globally in your system by this command

首先你需要通过这个命令在你的系统中全局安装laravel

composer global require laravel/installerthen you can install laravel by three ways, 1) Go to laravel githubReqosritory and download it's zip, and second it get ssh or Https url and install it from CMD or Git bash 2) open Git bash just write laravel newthere, this will download the latest laravel verision 3) open cmd or git bash and write there. composer create-project --prefer-dist laravel/laravel blogif you want to install some old version then you can write the mention the version in last. composer create-project --prefer-dist laravel/laravel blog 5.2.*

composer global require laravel/installer那么你可以通过三种方式安装laravel,1)去laravel githubReqosritory下载它的zip,然后它得到ssh或Https url并从CMD或Git bash安装它 2)打开Git bash只写laravel new在那里,这将下载最新的 laravel 版本 3) 打开 cmd 或 git bash 并在那里写入。 composer create-project --prefer-dist laravel/laravel 博客如果你想安装一些旧版本,那么你可以写在最后提到版本。 作曲家创建项目 --prefer-dist laravel/laravel 博客 5.2.*