Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Browse all series

How to Contribute to Open Source

Armed with a computer, some git knowledge, and an idea, any of us can contribute to the frameworks and packages that we use every day. Cool as that may be, it can initially be a daunting experience. 

So let's go on a journey together, as we take an idea for Laravel Prompts from musings to merging. Learning the basic processes will put you in good stead for contributing your own ideas.

Progress

Series Info

Episodes
13
Run Time
1h 49m
Difficulty
Intermediate
Last Updated
May 31, 2024
Version
Latest

Series Episodes

  1. The Pull Request (10)
    1. Selecting a Project

      So what are we going to contribute? Let's take a look at Laravel Prompts, a cool package that allows you to create beautiful CLI applications. There's a little feature I've been wanting to add for some time now that will make for a great Pull Request.
    2. Forking and Installation

      Before we can write any code, we need to install Prompts locally. This involves a little bit of git work, so we'll go through these steps together that you can then apply to any project you wish to contribute to.
    3. Getting a Feel for the Code

      You're going to be contributing to a project you've never worked on, with maintainers you've never worked with - already an uphill battle. That's why it's super important to get familiar with the codebase before you start hacking away at it. Let's take a brief look at how Prompts works.
    4. Build It Backwards

      One of my favorite ways to code is to create the final API before writing the implementation. This approach lends to clean code that is a joy to use. Let's write a script to demo usage of our steps idea.
    5. Script Driven Development

      Now that we have a script in place, we can use it to craft the implementation, which is sort of a play on TDD. We'll run the script each time we change the code until our script executes successfully.
    6. Working on Reverting

      Let's turn our attention to how reverting a step works. There are several scenarios we need to consider, so we'll keep hacking away using our playground script until we get the desired output in the terminal.
    7. Prove Your Work Works

      The majority of projects you'll contribute to will have tests in place, and the maintainers will expect you to add backing tests before they'll merge your contribution. Let's look at how Prompts' tests are organised and then begin to craft our own to back up the functionality we've added for steps.
    8. Refactor for Readability

      With tests in place, we can now confidently refactor to clean up our contribution before publishing it for the world to see. With each change we make, we'll re-run our step tests to make sure everything still works until we're happy with how the code looks and feels.
    9. Writing a Pr Description

      The time has come - it's time to create our Pull Request. As important as the code is, it's equally important that our PR description makes it easy for the maintainer and others to see exactly what we're trying to achieve. Let's take a look at the PR description I put together for steps.
    10. Fixing Failing Actions

      Gasp! Shock! Panic! The Github Actions are failing! Don't worry, it's usually just a simple tweak to get them green. In this case, Prompts uses PHPStan for type checking, so we'll need to run PHPStan locally and fix the errors we're seeing.
  2. Maintainer Feedback (2)
    1. Implementing Feedback: Part 1

      If your PR is more than a few lines of code, it's likely that the maintainer will have feedback with changes they'd like to see. In our case, we have some fairly extensive changes to make, so let's deal with those changes (both physically and emotionally) in the next couple of episodes.
    2. Implementing Feedback: Part 2

      Along with changing terminology from steps to form, Jess has also requested that we implement a cool idea she had for chaining prompts directly rather than passing closures each time. Let's see if we can get that working to complete our feedback checklist.
  3. Wrapping Up (1)
    1. So What's Next?

      It's time to celebrate! Our PR was merged, and you're now able to use this feature in Prompts. We did it! How cool is that? You've seen how to go from concept to completion with Open Source, on a fairly complex contribution. What will you do with your newfound knowledge? Let me give you a suggestion.

Continue Learning