PHP
Article
By Bruno Skvorc

Family CRMs, Guzzle Wrappers and PHP Machine Learning? Sourcehunt!

By Bruno Skvorc

It’s time for our monthly hunt for new open source libraries to use and contribute to!

If you’re new to Sourcehunt, it’s our monthly post for promoting open source projects that seem interesting or promising and could use help in terms of Github stars or pull requests.

It’s our way of giving back – promoting projects that we use (or could use) so that they gain enough exposure to attract a wider audience, a powerful community and, possibly, new contributors or sponsors.

--ADVERTISEMENT--

Sourcehunt logo


monicahq/monica [2,067 ★]

Monica blew up on Hacker News and ProductHunt the other day, and it was only fitting we mention it here despite having racked up well over 2000 stars already.

Monica is a Laravel-based single-user-CRM for personal relationships. Not for business, but literally for people in your life – tracking whom you haven’t bought gifts yet, money loans, birthdays, meetings, and more.

Monica promo screenshot

We think it’s half way through refreshing (because it’s something you don’t see often) and depressing (because do we really need apps to track the people in our life now?), but interesting nonetheless.

Due to the massive influx of interest from all over, Monica now has dozens of issues and several PRs ready for inspection, not to mention docs in need of fixing, a roadmap to plan, and more. If you want a popular project to contribute to, here it is!


genkgo/mail [3 ★]

Gengko/mail claims to be a modern reinvention of the PHP mailing libraries. In their own words:

While analyzing what mail library to use when refactoring a code base, we discovered that the available ones are mostly legacy libraries. Some do not use namespaces and every library we encountered were merely a collection of scalar property bags than objects using encapsulation. This is not a critique to these libraries. We all used them, and used them with joy. However, we think there is a need for new libraries that use modern principles.

Gengko’s mail is supposed to be used if you want to send e-mails over different transports and protocols using immutable messages and streams and if streams and Gengko in the same sentence sound familiar, it’s because we sourcehunted them before – only back then they were streaming zip files. Usage is dead simple and intuitive:

$message = (new FormattedMessageFactory())
    ->withHtml('<html><body><p>Hello World</p></body></html>')
    ->withAttachment(new FileAttachment('/order1.pdf', new ContentType('application/pdf')))
    ->createMessage()
    ->withHeader(new From(new Address(new EmailAddress('from@example.com'), 'name')))
    ->withHeader(new Subject('Hello World'))
    ->withHeader(new To(new AddressList([new Address(new EmailAddress('to@example.com'), 'name')])))
    ->withHeader(new Cc(new AddressList([new Address(new EmailAddress('cc@example.com'), 'name')])));

$transport = new SmtpTransport(
    ClientFactory::fromString('smtp://user:pass@host/')->newClient(),
    EnvelopeFactory::useExtractedHeader()
);

$transport->send($message);

This repo is in dire need of love: it needs stars, contributors, and mainly testers, so please dive in an help the team provide the PHP community with a new, modern, namespaced and encapsulated library ready for the PHP 7+ era.


kitetail/zttp [526 ★]

If you’re not familiar with the evolution of Guzzle (a PHP HTTP client we explore in the premium Exploring PHP course that’s available for purchase now), the library has basically gotten more professional and less usable with each new version. New layers upon layers of specification-respecting abstractions and rules made Guzzle incredibly difficult to get started with. Coupled with further abstractions like HTTPlug designed to prevent the old-Guzzle vs new-Guzzle conflicts, the situation in general just isn’t a pleasant one to develop in.

Enter ZTTP – a package that wraps Guzzle with some easy to use and approachable helper methods so that it once again becomes as usable as it once was. It was created by the testing god of Laravel: Adam Wathan, and knowing his code there’s not much to contribute with, but docs could use help and there’s always a need for usage examples and PRs with more convenient helper methods.


viacreative/sudo-su [324 ★]

There are many applications where being able to log in as a different user is a part of the business requirement – this is particularly popular in support, manuscript tracking, CRM, and similar applications where there’s a hierarchy of users. Sometimes, however, that functionality doesn’t end up in the final plans but would still be handy to have during development, just for testing the various permissions, UI options, etc.

The viacreative/sudo-su package adds to any Laravel app a small floating clickable widget which lets the current user log in as any other user in the system.

Package in use

The widget is disabled by default on all domains that don’t end in dev or .local – two telltale signs that a site isn’t in production, but this can be modified at will (our own Homestead Improved for example uses .app by default).

There are plenty of issues to tackle, so go ahead and jump in if you’re interested in finding out more about Laravel’s user authentication system!


IcyApril/WhatsChanged [22 ★]

The WhatsChanged tool is meant to assist in testing of large codebases with many tests. Since tests can take a while to execute, especially when dealing with the database or if there are hundreds of them, it’s handy to just re-run the tests that refer to the files that were changed.

This tool uses Git to track the changes on files and then reruns only the relevant ones – this includes changed tests. It has some rigid assumptions: it assumes your classes are in src and tests are mapped in the exact file structure in the tests folder. That sounds like a good thing to upgrade with a PR, no?

Contribute with things like Windows support or support for non-.php files and, of course, docs and examples!


php-ai/php-ml [3,497 ★]

Last but not least, the popular Machine Learning library for PHP. Not sure how we missed it earlier! This collection of ML algorithms ported to PHP comes with a comprehensive set of examples and explanations written in a way to be understandable by the intermediate-to-advanced PHP developer.

PHP-ML logo

The library requires modern PHP (7+) and is well documented.

There’s help wanted on several issues and more algorithms need to be added still, so if machine learning is something you feel like you could get into, why not contribute and learn more at the same time?


That’s it for June. Found anything you could sink your teeth into?

As always, please throw your links at us with the #sourcehunt hashtag! If you build something with the projects we’ve mentioned, or if you submit an elaborate pull request you’d like to talk about, give us a shout and we’ll make sure the world knows about it!

Like last time, (that challenge remains unclaimed, by the way – there’s $500 in it for you if you do it!), we’re using the above packages for inspiration on creating a potentially useful app or two:

App+Tutorial idea(s) of the month:

This month’s challenge is to upgrade Monica to support email reminders with Genkgo/mail, and multiple users (use the viacreative/sudo-su package during development), but who can all see the same contacts. However, each has their own dashboard with private info. Imagine your close family, and the family of your mother’s sister (so your cousins and aunt). Your mother could see on her dashboard (apart from her own notes) the birthday dates of this family and her relationship with her sister, while you could see your relationship with your cousins and make a note on how much money you loaned them last time you saw each other. This upgrade in the form of a tutorial is worth $500, so jump in – first come, first served! Get in touch!

Happy coding!

  • Ognjen Petrovic

    genkgo/mail tends to make mailing modern and more complex.
    kitetail/zttp wraps around the Guzzle to make it usable as it once was.
    Latter we will need something to wrap around the genkgo/mail to make mailing usable again :-)

    • Bruno Škvorc

      Haha, nice

    • Mr Egerton2013

      interesting. I have only used phpmailer. might as well look at its complexity.

Recommended
Sponsors
Get the latest in PHP, once a week, for free.