问题描述
我正在尝试使用 composer-file 创建一个项目.
Reason 主要是我不想上传到 git 的依赖项.
我的预期结构是这样的:
I'm trying to create a project with composer-file.
Reason is primarily a dependency which I never want to upload to git.
My intended structure is this:
项目根文件夹
- 项目子文件夹
- 供应商(具有 require
d 依赖项)
- index.php
- 作曲家.json
- README.md
但是使用composer安装的结构是这样的:
But the installed structure using composer is this:
项目根文件夹
- 供应商
- 供应商/作曲家
- 供应商/智能(依赖)
- 供应商/我的项目
- 作曲家.json
我知道许多不同的项目都有特殊的安装程序,但我只是不明白需要安装程序才能获得预期的结构,而且如果没有特殊的安装程序也不知道如何做到这一点.
I know that there are special installers for many different projects, I just don't understand that an installer is required to get the intended structure and also not how to do it without a special installer.
这是我试过的一个作曲家文件的内容:
This is the content of one composer file I tried:
{
"name": "wdb/tutorial-oop",
"require": {
"smarty/smarty": "~3.1"
}
}
当我在本地文件中尝试此 composer-json 内容并执行 composer install
我得到相同的结构:
When I tried this composer-json content in a local file and just extecute composer install
I get the same structure:
{
"require": {
"wdb/tutorial-oop": "dev-master"
}
}
所以我的问题是,一个作曲家文件必须如何看待项目结构的创建,就像我在这个问题的顶部所描述的那样.基本问题是我不希望我的项目作为依赖项安装在供应商目录中,而是安装在项目文件夹的根目录中,另外我不想使用 composer 自动加载器.
So my question is, how a composer file has to look that the project structure is created like I described in the top of this question. The basic problem is that I don't want my project being installed as dependency in the vendor-directory but in the root of the project folder, and additionally that I don't want to use the composer autoloader.
根据要求,我在项目根目录中的完整作曲家文件:
On request here my full composer file inside the project root:
{
"name": "wdb/tutorial-oop",
"type": "project",
"description": "Your package description goes here",
"keywords": ["oop","mvc","tutorial"],
"homepage": "https://barlians.com",
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "David Bruchmann",
"email": "[email protected]",
"homepage": "https://barlians.com",
"role": "Author, Developer"
}
],
"support": {
"email": "[email protected]"
},
"require": {
"smarty/smarty": "~3.1"
}
}
推荐答案
您安装项目的方式不正确.composer require
命令是用来安装依赖的,所以他们会去 vendor
目录.
You're installing your project in incorrect way. composer require
command is for installing dependencies, so they're go to vendor
directory.
对于安装项目,您应该使用 create-project
命令:
For installing project you should use create-project
command:
composer create-project wdb/tutorial-oop
这篇关于带有作曲家的项目结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!