David's Coding Blog

"Don't reinvent the wheel"

You can find many posts on Reddit, Stack Overflow, etc. that tell you not to reinvent the wheel. "Just use a library or framework that already does what you need to solve your problem." This is fine for a work environment where quick results are desired.

What about hobby projects? Should you use existing packages for everything?

I think that hobby projects can be used to learn more about the inner workings of frameworks or libraries that we use.
After using the PHP framework Laravel at work, I knew how to use the features that Laravel provides, but I never thought about how they are implemented.

I used my self-written web-based ERP system for managing certified organic land called Bio-Manager to fix that. I used a basic PHP router class and extended it so that it can be configured similar to Laravel. After that I added a migration system. This was followed by the addition of a CLI with the ability to add custom commands, a query builder, etc.

The trick is the reduction of the feature in smaller simpler tasks. Using the example of the migration system:
The first step was to define an interface that every migration must implement. Next, a simple example of what a migration file might look like was created. Then a migration runner was implemented that could find every migration file in the specified folder and load it. The last step to get the simplest version up and running was a table to keep track of the migrations already done.

Done. Now I could use it. And... I stepped over the next problem while adding support for SQLite. My migrations contained plain SQL that was executed to create or modify tables. So the next step was to add a table schema class that could generate the SQL for every supported database system. And step by step, a lot of Laravel-like features were added to my own PHP framework.

What did I learn?

Without looking at the code of the Laravel framework itself, I was able to understand the limitations I was running into while using Laraval at work. This was because I had to solve the obstacles I encountered when implementing such a feature myself.

Conclusion

You need to have the motivation to dive deep into the obstacles you encounter. But you will gain a very deep understanding of the tools, frameworks, or libraries that you use every day at work or in other hobby projects.