Among the many software principles to adopt, like KISS eYAGNI, another important one is DRY (Don’t repeat yourself), IMO connected to the Standing on the shoulder of giants principle. In other words: Great people already faced your problems, solved them elegantly and also published their solution. So why not using highly skilled people’s solutions instead of developing yours ?
Unless you do things for learning, it’s more efficient to re-use things and avoid reinventing the wheel. Is, therefore, important to learn how to contribute to export and distribute some code to the public. Below, a list of some libraries I’ve exported from some projects of mine because I thought I’d use them in the future, or somebody else would need them.
A few years ago I developed a component to convert GBP into EUR for a client who needed an auction website and price filtering in different currencies. No PHP library was available at the time (not sure there still is one), so I’ve developed this unit-tested parser able to read values from the European central bank feed. I’ve used it a couple of time since then, so it was a good idea exporting it. If I need to convert currencies, it’ll take minutes to add this to the project. Note: the library doesn’t download and cache the feed on purpose. I prefer to have repositories doing one thing only. Downloading and caching is a responsibility of the caller, and it could be doctrine caching and a simple PHP file_get_content or guzzle call, depending on what you already use in your project.
Mockery (PHP stubs framework for testing) allows to mock chains of called methods, but no arguments can be specified. If your arguments are strings or integers, you can use this simple extension and write the same assumptions in a simpler way.
I couldn’t find a simple twig extension to limit some text by the number of words (without truncating them), and – in case they are truncated – add a suffix like “continue …”. Also, there was nothing to remove accents (useful to Slugify), so I created this unit-tested one, where I’ll add more general purpose Twig filters in the future.
A simple extension of doctrine array collections that already work great, but a.t.m. misses functionalities like sorting, create a new one from a merge of multiple arrays/collections, get not empty values.
Very simple and worth exporting. It’s unit tested, so I next time I need to work with a ArrayCollection, I’ll add this repo to the composer file and save time. Besides, any improvements will get saved into the repository itself, and not into a private project that might be abandoned, and therefore not lost.
Simple WordPress Woocommerce plugin to order woocommerce layered navs filters by order descending. Took minutes to implement.
Google Tasks web client, displaying all the lists on one page, functionalities to drag and drop tasks from one list to another. Written with AngularJs and Silex. I’ve abandoned this project due to some priorities, but some parts of it could be useful for similar projects. Sorry, no demo available
There are free language dictionaries on the web, but no open source library to parse them.
I’ve created one, that can be used for auto text spinning or suggesting synonyms.