简体   繁体   English

如何将自定义 laravel 包添加到 git?

[英]How to add a custom laravel package to git?

I developed a custom laravel package that is located under packages/vendor/name .我开发了一个位于packages/vendor/name下的自定义 laravel 包。 As I created all the files there, it is now part of my main app's git repo.当我在那里创建所有文件时,它现在是我主应用程序的 git 存储库的一部分。

  • 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 ?我是否需要将packages/*文件夹添加到主应用程序的.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?我是否需要将我的包从主应用程序中复制出来,对其进行git init并将其推送到它自己的存储库,然后composer require它回来? 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:我不熟悉 laravel,但我想你在这里有几个选择:

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?我是否需要将我的包从主应用程序中复制出来,对其进行 git 初始化并将其推送到它自己的存储库,然后作曲家需要它回来? 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.同时,如果您不能将包发布到您的框架的 pakage 存储库,您可以将它推送到它自己的存储库并手动更新您的软件。 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?我是否需要将 packages/* 文件夹添加到主应用程序的 .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.如果您要以这种方式添加另一个包,请不要将该文件夹添加到 gitignore,因为 git 仅通过网络提交增量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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