PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 5, 2022

[FIXED] Setup a project with Composer by using custom repositories and packages

 March 05, 2022     composer-php, namespaces, php     No comments   

Issue

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


Solution

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.



Answered By - jarodium
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing