Skip to content
Luca Ubiali Web Developer

How to Contribute to Open Source - 3/13 - Getting a Feel for the Code

August 12th, 2024
Continuous Learning

Episode - https://laracasts.com/series/how-to-contribute-to-open-source/episodes/3


The suggestion is to familiarize with the existing code before start writing our own. This will give us more chances to create a PR the maintainer will approve, rather than reject with major revisions or close altogether.

Prompts includes a playground folder with samples. Likely any change we will do to a prompt will have to be included here as well.

A playground file for the Confirm prompt is a perfect spot to start a source dive.

From there we can jump into the main ConfirmPrompt class and its parent class Prompt. The interesting bit is that a Prompt class is only responsible for the internal state of the prompt. Any rendering of the prompt is done by a corresponding Renderer class. So ConfirmPrompt is paired with a ConfirmPromptRenderer class.

Looking forward to dive into the Renderer logic later on in this series, but already now it’s interesting to see how state management and presentation as split. This will allow to create a completely new “theme” for prompts just by adding new Renderer classes. Nice pattern!

Now the structure of the package is much clearer. Depending on the changes needed we’ll know in which class add our edits.