Breaking down the packages for a swapping compatability.
Posted on 06 June 2018 at 02:55:37PM.
While working in my open-source projects during my spare time, I occurred some epiphanies for both Credo and Wildfire. Both are PHP libraries that supplement the Codeigniter 3 framework, which I used as a foundation for some of my projects before. Each library has a purpose to be on top of something. Like for Wildfire is on top of Codeigniter's Query Builder while Credo is just a wrapper for the Doctrine's Object Relational Mapper (ORM).
A part of that epiphany is that my naming convention has changed over the years. Even I blindly followed the PSR-2 standard before, but now I liked to deviate from the standard gradually. I even go to a thesaurus website to find a single word that means two words just fit my own criteria. Since then, I was on cringe when seeing CodeigniterModel
instead of Model
only.
One of those epiphanies is the possible swap compatibility. Since the minimum PHP version of each library is on v5.4.0, I used traits back then for extending the functionalities for each library like the ValidateTrait and PaginateTrait. However, those traits in each respective libraries have different parameters and thinking that they share the same concept, it could be challenging in swapping them back and forth.
A huge epiphany came from Zapheus, the framework that was currently working on in the past few days. I was inspired that "extending" a third-party requires to respect its codebase as well as to respect the framework they were extending to. In the case of both Credo and Wildfire, I need to make them follow the naming conventions of the Codeigniter 3 framework while not compromising the syntax from the third-party libraries.
With those epiphanies and my less interest in the Codeigniter 3 framework in general, I initially just scrap those and leave it in my thoughts. However, when I go to Github's homepage, I saw some people giving stars to Credo and Wildfire. And then I realized that those people really use those. Even someone sent me an email about why those libraries lack documentation. Being pumped and happy that someone uses them, I decided then to refactor both Credo and Wildfire.
For weeks, I started them off from scratch. For Wildfire, I decided to imitate its functionalities similar to Laravel's Eloquent, since they use a similar pattern (ActiveRecord) but overall, the method names just coincide with the Codeigniter's Query Builder. While for Credo, I created a CredoTrait that could be injected into a Codeigniter Model then set its method names that nearly identical to Codeigniter's Query Builder and also added magic methods for accessing Doctrine ORM's official functionalities.
After publishing those libraries, the documentation for each library is now identical. With the difference from the properties being included in the Codeigniter Model. I needed to make documentation as well for migrating from the previous version since the syntax was different. Overall, my itch was scratched, and it was great to see that those libraries can be swapped easily with minimal effort. Of course, there are room for improvement as well, but we could just call it a day instead.