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

Friday, January 21, 2022

[FIXED] PHP Developing a composer package under vendor of the main project

 January 21, 2022     composer-php, github, php     No comments   

Issue

I have a main php project that needs a php component developed by me, that i intend to reuse in other projects, the component is in the main project vendor directory. However pushing to Github the component, go to the main project, running composer update is time consuming. In order to speed up the development of the component, is there a way to include the local component project into the main project?


Solution

This is how I do local composer package development.

  1. Create a vendor-repo folder next to the vendor folder.
  2. Create a directory for the vendor and project name for example vendor-repo/vendorname/packagename
  3. Create a git repo inside the packagename folder and build your composer package complete with composer.json etc.
  4. Add your local repository to the main composer.json (the one that requires your package). You can also disable the packagist repo by adding the "packagist": false as per the example below. This will speed things up and is a good idea if you aren't using any packages from packagist.

"repositories": [ { "type": "path", "url": "vendor-repo/vendorname/packagename" }, { "packagist": false } ]

Then when you run composer update it will get your package from your local repo rather than needing to get it from GitHub.



Answered By - developerbmw
  • 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