如何使用Composer将软件包打包到Laravel项目中 [英] How to Require Package Into Laravel Project with Composer

查看:33
本文介绍了如何使用Composer将软件包打包到Laravel项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Laravel和Composer的新手,并且正在遵循包括LaraCasts.com在内的一些指南.需要做的事情之一是使用Composer要求在Laravel项目中使用软件包.但是,这对我不起作用.

I am new to Laravel and Composer, and am following some guides including LaraCasts.com . One of the things that need to be done is use Composer to require packages to use in the Laravel project. However, this doesn't work for me.

我使用 composer create-project 方法( http://laravel安装了Laravel.com/docs/5.0 ),到目前为止,一切都很好.但是,我现在需要"的所有程序包实际上都进入了C:\ Users \ user \ vendor文件夹,并且composer.json文件位于C:\ Users \ user中.

I installed Laravel using the composer create-project method (http://laravel.com/docs/5.0), and so far everything was fine. However, any package I "require" now actually goes into the C:\Users\user\vendor folder, and the composer.json file is in C:\Users\user.

我知道Composer应该在项目之间分开,而不是像PEAR这样具有全局性.那么,如何指定我正在处理一个特定项目并要求该项目中包含所有内容呢?另外,万一我想手动将包裹放在Laravel中,实际的路径是什么?

I understand that Composer is supposed to separate between projects as opposed to being global like PEAR. So how do I specify that I'm working on a specific project and require everything into that project? Also, what is the actual path where I'm supposed to put packages in Laravel, in case I want to do it manually?

我正在使用Windows 7和Xampp.

I am using Windows 7 and Xampp.

推荐答案

运行 composer require {pacakage} 时,请确保使用 cd 命令(更改目录-我认为)进入您要为其安装软件包的项目.因此,如果您使用的是Xampp,则可能类似于 cd C:\ xampp \ htdocs \ my-laravel-project \ 或项目的路径,然后运行您的 composer require{pacakage} .

When you run composer require {pacakage}, make sure you use the cd command (Change Directory - I think) into the project you want to install the package for. So if you're in Xampp it could be something like cd C:\xampp\htdocs\my-laravel-project\ or whatever the path to your project is, then run your composer require {pacakage}.

我相信它将在 C:\ Users \ user \ vendor 中安装,因为当您打开终端/命令提示符时,默认位置是 C:\ Users \ {username} \ .

I believe it's installing it in C:\Users\user\vendor as when you open your terminal/command prompt the default location is C:\Users\{username}\.

请确保您在Web根目录中运行过 composer create-project ,对于Xampp,我认为它是 C:\ xampp \ htdocs \ ,但根据情况可能有所不同有关如何安装Xampp的信息.

Please make sure you ran the composer create-project in your web root, for Xampp I think it's C:\xampp\htdocs\ but it could be different depending on how you set up Xampp when you installed it.

这篇关于如何使用Composer将软件包打包到Laravel项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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