1
votes

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": "[email protected]",
            "homepage": "https://barlians.com",
            "role": "Author, Developer"
        }
    ],
    "support": {
        "email": "[email protected]"
    },
    "require": {
        "smarty/smarty": "~3.1"
    }
}
1
You should not add your project to require section. You already have it, you don't need to install it again.rob006
@rob006 I did it only in the last local composer file and executed with "composer install". That's the same I think like on commandline composer require my/projectDavid
composer just handles and touches the vendor folder. and directly a tip: if you are new to composer, do not write composer.json manually. and have a look in vendor/composer - it will be the autoloadersNorman M
@NormanM thanks, what you propose how to create the composer file?David
@NormanM concerning autoloader I know composer is offering that. I just wrote an own one especially for this project.David

1 Answers

2
votes

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