如何安装 Laravel 5.0

2021-12-18 00:00:00 php laravel laravel-5 composer-php

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

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

{错误":{"type":"ErrorException","message":"未定义索引:时区","文件":"/Projects/indatus/dispatcher-test-app/vendor/laravel/framework/src/Illuminate/Foundation/start.php",线":167}}{错误":{"type":"ErrorException","message":"未定义索引:时区","文件":"/Projects/indatus/dispatcher-test-app/vendor/laravel/framework/src/Illuminate/Foundation/start.php",线":167}}

我是不是完全遗漏了什么?

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

解决方案

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

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

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

您也可以使用替代方法

composer global require "laravel/installer=~1.1"

然后运行

laravel new test-laravel-5-project

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

<小时>

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

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

一步法

你只需运行:

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

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

多步法

  1. 使用选项下载https://github.com/laravel/laravel/tree/develop下载邮政编码
  2. 解压到web目录
  3. 在解压 ZIP 文件的目录中运行 composer update(不是 composer install)

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

这两种方法都应该很好用.试一试,选择最适合您的那个.

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

1) Creating a new app from https://github.com/laravel/laravel/tree/develop leads to the following error when running 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 Documentation for how to install Laravel

解决方案

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

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

in your console. test-laravel-5-project is 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

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


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

I've just tested this and there are two ways of installing 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-project is 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)

Multi-step method

  1. Download https://github.com/laravel/laravel/tree/develop with option Download ZIP
  2. Unpack it in web directory
  3. Run composer update (not composer install) in directory where you unpacked your ZIP file

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

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

相关文章