We work with a lot of open source code and tools. Because of the nature of software, there are a lot of times when these tools are missing features we end up adding in, and when possible, it's nice to contribute back. Sometimes patches are accepted, and sometimes they are not, but it never hurts to share code with a broader community in the event that someone might find the enhancements useful. Here’s what I have found that makes for a successful open source contribution more often than not:
Gauge interest & do some research
Not completely necessary, but has this feature been requested? Has the project maintainer made positive comments around similar features? Has someone already written the same thing you were interested in and there is an outstanding pull request? You can learn a lot from looking through GitHub issues alone.
Pick a reasonable scope
Best to stay away from any major overhauls. Unless you have the blessing of the core contributors, focus on one or two new features. This means less code, less tests, less review, and most importantly, less barrier to acceptance. Just like any software project, the smaller the scope, the better chance it has.
Follow the conventions and rules
Don’t rustle any feathers. If there are contributor guidelines, be sure to review them. When writing your code, follow all of the styles and conventions that are already in place. This alone makes your enhancements look like they belong. It’s valuable to analyze the way someone else has written something even if, in the end, you still prefer your own style. As far as PHP is concerned, PSR-1 and 2 have helped out somewhat with defining best practices for style, but there are still plenty of libraries that don’t conform, so do your best to fit in.
Be complete in your enhancement
Is all of the code you wrote properly commented? Is there documentation or a user guide that needs to be modified as well? Have you written tests? Did the tests pass? I’ve seen so many abandoned patches/enhancements simply because the author just threw together some code without taking the time to finish the job. Frankly, any new features without tests or docs are pretty much worthless to the project maintainer. Be sure that all bases are covered before you submit anything back to the project.
Clearly communicate the details
When you’re ready to submit your features back, most likely through a pull request, be sure to describe your feature in detail. Explain the problem it solves and dive into the specific use case that you felt needed to be addressed. A nice quick code example of how the new feature works is ideal, with a link to more details if necessary. It also can’t hurt to have a pleasant tone and conclude by thanking the project maintainer for taking the time to review your enhancement.
None of this is a guarantee for a successful enhancement to an open source project. If you’re lucky or have a good reputation, it could be accepted right away, but most likely, the maintainer will have some changes they want made before accepting and you can work with them to do so. Still, by following these general guidelines, you have a pretty good chance of becoming a productive contributor to an open source project.