简体   繁体   中英

Setup a project with Composer by using custom repositories and packages

I am trying to setup a composer project that will enable me to setup my own framework and pulling out any given dependency stored in github private repos.

First some prerequisites:

  1. I don't want to add code to packagist.
  2. I want to make sure my vendor folder is as clean as possible.

Framework composer.json

{
    "name": "mycompany/myframework",
    "description": "YET another Framework",
    "type": "project",        
    "repositories": [
        {
          "type": "package",
          "package": {
             "name": "mycompany/system",
             "version": "0.0.2",
             "type": "library",
             "source": {
                "url": "https://github.com/mycompany/system.git",
                "type": "git",
                "reference": "master"
             }            
          }
       }
   ],
   "require": {                
       "mycompany/system": "0.0.2",
       "mnsami/composer-custom-directory-installer": "1.1.*"        
   },    
   "license": "proprietary",
   "authors": [...],      
   "extra":{
       "installer-paths":{}
   }
}

mycompany/system composer.json

{
    "name": "mycompany/system",
    "type": "library",
    "description": "utility belt xD"
}

The code for the class in PHP ( from mycompany/sytem ) has the following structure:

namespace MYCOMPANY;
//this file name is called utils.php
//adherence to PSR-4 is assumed
class utils  {

}

My goal is:

I want to tell composer that it should create the following structure:

vendor \ MYCOMPANY \ utils.php ( not vendor \ mycompany \system \utils.php )

Later on, I want to be able to add more repositories like this and store them under MYCOMPANY as well. The framwework will work around this setup.

Custom installation is handled by mnsami/composer-custom-directory-installer

I'm guessing I should keep, by rule of thumb, the different packages in their own directories, but, since there is no risk of overwriting because other files will have a different naming convention.

Edit Can this be done? If so, how?

Thank you in advance

After some hours of work and following on @NicoHaase's reply in the comments, I gave up on this issue.

I was trying to make a clean folder where I would put all the different classes from different repos, but composer just doesn't work that way.

I hope this will help others that want the same thing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM