我应该为每个项目下载Laravel吗? [英] Should I download Laravel for every project?

查看:146
本文介绍了我应该为每个项目下载Laravel吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Laravel创建了一个项目,并通过以下命令从 git 下载:

  git clone -b develop git://github.com/laravel/laravel.git 

文件大小约为21MB,

我想知道是否应该使用此命令为每个项目下载Laravel?



您应该使用作曲者来安装您的Laravel项目。您还将在上述项目中使用Composer进行其他与依赖项相关的操作(包括自动加载)。这是安装新的Laravel框架以开发网站的正确方式:

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

http://laravel.com/docs/installation



然后,您创建的任何未来的Laravel项目都将从您的Composer缓存,而无需重新下载。



Composer软件包还设置了所有供应商相关的 .gitignore 信息,并包含其他几个非常有用的管理功能。这很重要,因为您只想将特定于应用程序的代码保存在 git 版本控制下,不是框架本身或任何其他依赖项。 (否则,您的差异和提交会受到依赖项的开发更改的污染。)



一旦为项目创建了存储库并使用Composer安装了Laravel,并创建了你的第一批提交(例如一些迁移,模型和控制器),克隆你的项目通常是这样的:

  cd / clone-here 
git clone / myproject#当前项目的位置
#/ clone-here现在只有来自/ myproject的特定于应用程序的文件。它是
#仍然缺少框架本身和其他依赖项。
composer install#Composer现在查看
#/clone-here/composer.json中的依赖关系,并将它们安装到包含Laravel框架的/ clone-here / vendor
#中。
#现在框架和其他依赖关系很好。
php artisan migrate#Laravel从您的迁移中创建所有数据库模式
php artisan db:seed#将您可爱的新数据库表种下

一旦您习惯了它,它真的很优雅和有趣。



编辑:
请参阅 Sheikh 回答,以节省一些时间作曲家安装过程!


I created a project with Laravel and downloaded from git via this command:

git clone -b develop git://github.com/laravel/laravel.git

The file size was about 21MB,

I want to know should I download Laravel for every project with this command?

解决方案

What you have done is cloned the framework itself, which you should only do if you're going to fork and develop the Laravel core.

What you should do instead is use Composer to install your Laravel projects. You'll also be using Composer for other dependency-related actions in said projects (including autoload). This is the proper way of installing a fresh Laravel framework for developing a website:

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

http://laravel.com/docs/installation

Then, any future Laravel projects you create will be loaded from your Composer cache without needing to re-download.

The Composer package also sets up all your vendor-related .gitignore information and includes several other really useful management features. This is important, because you only want to keep your application-specific code under git version control, not the framework itself or any other dependencies. (Otherwise, your diffs and commits will get polluted with the dependencies' development changes.)

Once you've created a repository for your project, and installed Laravel with Composer, and created your first few commits (with some migrations, models, and controllers, for instance), cloning your project usually works something like this:

cd /clone-here
git clone /myproject # Location of current project
# /clone-here now has only the application-specific files from /myproject.  It is 
# still missing the framework itself and other dependencies.
composer install  # Composer now looks at the dependencies in 
                  # /clone-here/composer.json and installs them into /clone-here/vendor
                  # including the Laravel framework.
# Now the framework and other dependencies are good to go.
php artisan migrate # Laravel makes all your DB schemas from your migrations
php artisan db:seed # Seed your lovely new DB tables

It's really elegant and fun once you get used to it.

Edit: See Sheikh's answer to save some time in the Composer install process!

这篇关于我应该为每个项目下载Laravel吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆