Project Structure with composer

自闭症网瘾萝莉.ら 提交于 2019-12-31 07:25:09

问题


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:

project-root-folder
- project-sub-folder(s)
- vendor (with required dependencies)
- index.php
- composer.json
- README.md

But the installed structure using composer is this:

project-root-folder
- vendor
- vendor/composer
- vendor/smarty (dependency)
- vendor/my-project
- composer.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"  
    }
}  

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"  
    }
}  

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.

Edit:
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": "david.bruchmann@gmail.com",
            "homepage": "https://barlians.com",
            "role": "Author, Developer"
        }
    ],
    "support": {
        "email": "david.bruchmann@gmail.com"
    },
    "require": {
        "smarty/smarty": "~3.1"
    }
}

回答1:


You're installing your project in incorrect way. composer require command is for installing dependencies, so they're go to vendor directory.

For installing project you should use create-project command:

composer create-project wdb/tutorial-oop


来源:https://stackoverflow.com/questions/52271391/project-structure-with-composer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!