简体   繁体   中英

How to add a custom laravel package to git?

I developed a custom laravel package that is located under packages/vendor/name . As I created all the files there, it is now part of my main app's git repo.

  • What is now to correct way to maintain that package in it's own repo?
  • Do I need to add the packages/* folder to the main app's .gitignore ?
  • Do I need to copy my package out of the main app, git init it and push it to its own repo and composer require it back? If yes, isn't it complicated to update the package later?

I am not familiar with laravel, but I guess you have several options here:

What is now the correct way to maintain that package in it's own repo?

The radical way would be to eventually publish the package in your framework's package repository, and then integrate your package with your favorite automated package management tool, but there might be reasons you are not doing like this.

Do I need to copy my package out of the main app, git init it and push it to its own repo and composer require it back? If yes, isn't it complicated to update the package later?

In the meantime, if you can't publish the package to your framework's pakage repository, you could push it to its own repository and update your software manually. It is usefull to decouple your app codebase from a specific versions of your custom package. Loose coopling if often something that is looked for in effective software design, as it avoid breaking changes.

Do I need to add the packages/* folder to the main app's.gitignore?

If you are going to add another package this way, don't add the folder to gitignore, since git only submit deltas over the network.

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