PHP
Article
By Bruno Skvorc

Sourcehunt September – Hacktoberfest Edition

By Bruno Skvorc

It’s that time of year again – DigitalOcean’s Hacktoberfest is starting!

It’s a month-long open source effort when people are encouraged to contribute to various open source projects (not their own!). Anyone who opens 4 pull requests (even documentation fixes count!) gets a T-shirt at the end of the month, symbolizing their engagement in the open source community.

Of course, open source is much more than just a single month, but for people who don’t generally take the time to contribute to other developers’ projects, it’s more than a good start.

If you’d like to participate, why not pick some of the projects from the list we’ve compiled this month? And if these don’t tickle your fancy, why not visit the sourcehunt PHP tag and see if you can find something more interesting?

Let’s dive in!

Sourcehunt logo


kodus/mail [3 ★]

Just as we published our Fighting Recruiter Spam with PHP post, using Swiftmailer to send replies, Kodus got submitted to Sourcehunt.

Kodus/mail is a brand new alpha-level package designed to make sending UTF-8 email even simpler, while at the same time skipping all the legacy baggage Swiftmailer drags along with it (old school autoloading, naming conventions, etc.). As the author says, the aim is to “start over with modern PHP and a limited scope in terms of features, for the sake of simplicity.”

Here’s your chance to get in on the ground floor of a very promising project!


voku/Arrayy [20 ★]

Arrayy is a very powerful and versatile object oriented interface for array manipulation. As the README intro says:

Arrayy::create(['Array', 'Array'])->unique()->append('y')->implode() // Arrayy

This is just one of the near infinite number of possible chains of operations that Arrayy provides. Other usages include things like:

createFromString(string $str) : Arrayy (Immutable)

Create an new Arrayy object via string.

$arrayy = A::createFromString(' foo, bar '); // Arrayy['foo', 'bar']
append(mixed $value) : Arrayy (Mutable)

Append a value to the current array.

alias: “Arrayy->add()”

a(['fòô' => 'bàř'])->append('foo'); // Arrayy['fòô' => 'bàř', 0 => 'foo']
containsCaseInsensitive(string $value) : boolean

Check if an (case-insensitive) string is in the current array.

a(['E', 'é'])->containsCaseInsensitive('É'); // true
each(Closure $closure) : Arrayy (Immutable)

Iterate over the current array and modify the array’s value.

$result = A::create();
$closure = function ($value) {
  return ':' . $value . ':';
};
a(['foo', 'bar' => 'bis'])->each($closure); // Arrayy[':foo:', 'bar' => ':bis:']
find(Closure $closure) : mixed

Find the first item in an array that passes the truth test, otherwise return false.

$search = 'foo';
$closure = function ($value, $key) use ($search) {
  return $value === $search;
};
a(['foo', 'bar', 'lall'])->find($closure); // 'foo'
randomWeighted(array $array, int|null $take) : Arrayy (Immutable)

Get a random value from an array, with the ability to skew the results.

a([0 => 3, 1 => 4])->randomWeighted([1 => 4]); // e.g.: Arrayy[4] (has a 66% chance of returning 4)
searchValue(mixed $index) : Arrayy (Immutable)

Search for the value of the current array via $index.

a(['fòô' => 'bàř'])->searchValue('fòô'); // Arrayy[0 => 'bàř']
toJson() : string

Convert the current array to JSON.

a(['bar', array('foo')])->toJson(); // '["bar",{"1":"foo"}]'

… and much, much more. The project has been out for a while, but has yet to achieve widespread adoption despite being fully tested and well documented, so let’s hope Sourcehunt helps!


voku/portable-utf8 [76 ★]

Made by the same person who made the above Arrayy package, portable-utf8 is an implementation of UTF-8 in PHP without any extension prerequisites. In other words, whether or not your server has the UTF-8-friendly extensions installed, UTF-8 will be enabled on your server. If the extensions are missing, polyfills from Symfony will be used.

I’ll let the “why” section tell you why this exists:

PHP 5 and earlier versions have no native Unicode support. To bridge the gap, there exist several extensions like “mbstring”, “iconv” and “intl”.

The problem with “mbstring” and others is that most of the time you cannot ensure presence of a specific one on a server. If you rely on one of these, your application is no more portable. This problem gets even severe for open source applications that have to run on different servers with different configurations.

It’s important to note that if you’re already using some UTF-8-specific functionality in your app, transitioning to this package is less than straightforward since it’s not a drop-in replacement. Due to the package’s nature, it’s also worth keeping in mind that it’ll become a hard dependency. Still, considering the gains, it seems worth it.

The package has no open issues or pull requests, and no TODOs defined, but its test coverage and Scrutinizer score could use some work, so if you’re looking to contribute by optimizing test levels and perceived code quality, now’s your chance.


php-integrator/atom-base [168 ★]

PHP-integrator is an Atom package which helps with code linting – i.e. adds many of the useful code completion and code hinting features from PhpStorm to Atom.

It’s currently dependent on Atom in that it’s an Atom package, but its PHP code can easily be extracted and applied to another editor with hooks that make integration possible.

It could use some more features on the Atom side, but it could also use a fork or two turning it into an editor-agnostic package that can be easily applied to any other IDE. Another idea – why not make it work with Docker out of the box, helping people avoid having to have PHP installed on their host operating systems? Dive in!


--ADVERTISEMENT--

florianv/exchanger [7 ★]

This package is a “currency exchange framework”, meaning it’s used to develop currency exchange packages. Think of it as a standard to help you with developing your own interchangeable currency exchange package.

One interesting implementation of this “framework” is the popular Swap package by the same author.

While both packages are quite mature, Exchanger could use a little more love.

By the way, if you’re interested in writing about Exchanger and demonstrating the framework’s power, get in touch – we’re looking!


rinvex/country [383 ★]

As the description says:

Rinvex Country is a simple and lightweight package for retrieving country details with flexibility. A whole bunch of data including name, demonym, capital, iso codes, dialling codes, geo data, currencies, flags, emoji, and other attributes for all 250 countries worldwide at your fingertips

Example:

use Rinvex\Country\Models\Country;

// Find a country by it's ISO 3166-1 alpha-2
$egypt = (new Country)->find('EG');

// Find a country by one of it's attributes
$usa = (new Country)->findBy('capital', 'Washington D.C.');

// Find all countries
$countries = (new Country)->findAll();

// Retrieve only `name`, `demonym`, and `currency` attributes of "Japan":
$japan = (new Country)->find('JP', ['name', 'demonym', 'currency']);

// Utilize Laravel Collections to get an array of all country names, with their 'iso_3166_1_alpha2' as the array keys
$allCountries = (new Country)->findAll()->pluck('name.common', 'iso_3166_1_alpha2');

As someone who’s building two separate geo-aware apps at the moment, I can definitely appreciate this package – it makes things much easier in regards to common country information.

Due to its versatile documentation and excellent code quality score, the library already sports some decent adoption, but could still use more users and more contributors. Can you help out? There are also some issues you can tackle right now!


ScriptFUSION/Mapper [7 ★]

I honestly have no idea what this is or what I’d use it for, but Ocramius praised so I included it in the list.

If you feel like you can explain what this is to total newbies, please get in touch and we’ll pay you for the post.


lufficc/laravel-blog [164 ★]

A Laravel 5.3 blog system! Judging by the feedback, it’s quite good, but could definitely use more features. Why not chime in and help out?

Let us know if you do – we’d love a thorough analysis!


Corollarium/PSR6-ProfileCachePool/ [9 ★]

Do you use PSR-6 cache? If so, you might be interested in this profiler which monitors how many hits and misses your cache implementation gets. It’s not really useful unless you’re noticing some discrepancies and want to debug, but it’s here if you need it!

Why not contribute to the package by adding some more report formats (animated graphs?) or other statistics to track?


That’s it for September – as always, please throw your links at us with the #sourcehunt hashtag! Now go forth and Hack through Hacktober! Let us know what you did and happy coding!

Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account