How to Analyze Tweet Sentiments with PHP Machine Learning

Machine learning is rarely mentioned in the same sentence (or article, for that matter) with PHP, so each time this happens, I’m all ears.  Here’s one that I came across recently – How to Analyze Tweet Sentiments with PHP Machine Learning.

Unlike many other “hello world” kind of examples, this article examines a real and quite common problem, which can be easily adopted to other similar problems – SPAM filtering, marketing segmentation, fraud detection, etc.

AutoMapper – Declarative data mapper for PHP 7

AutoMapper can map data from array/object to existing array/object or marshal a new one.

Mapping rules specified in declarative way using three simple definitions:

  • From definition (From::create or via short function from) — maps single field from source to target. Supports chainable functions:
    • ->convert(callable $callable) — converts input value to another one via any callable;
    • ->trim() — trims value to eliminate whitespaces (suitable for strings);
    • ->default($defaultValue) — returns default value if source field is missing;
    • ->ignoreMissing() — ignores target field if source field is missing;
    • ->ignoreEmpty() — ignores target field if source field is empty.
  • Aggregate definition (Aggregate::create or via short function aggregate) — maps multiple fields from source to single target field. Supports chainable functions:
    • ->trim() — trims aggregated value
    • ->ignoreEmpty() — ignores target field if aggregated value is empty.
  • Value definition (Value::create or via short function value) — maps constant value to target field. Supports chainable functions:
    • ->trim()
    • ->ignoreEmpty()

All missing source fields can be ignored via AutoMapper::create(...)->ignoreAllMissing() modifier.

Vim as a PHP IDE – the complete guide

Vim as a PHP IDE – the complete guide” is yet another one of those lengthy articles on how to setup Vim as an IDE (Integrated Development Environment), specifically so for PHP developers.

Over the years, it’s interesting to see how with more powerful Vim, such guides become more and more focused on the selection and configuration of the plugins, rather than on tweaking Vim configuration.

HTTPlug – The HTTP client abstraction for PHP

HTTPlug is an HTTP client abstraction for PHP.  Using this library you can decouple your code from the specifics of the HTTP implementation in your client of choice, and can also easily switch between different clients, like cURL, Guzzle, and so on.

HTTPlug also supports pluggable functionality, so you can expand or shrink as needed by your application.  Some examples of plugins include request / response logging and authentication.

How to Read Big Files with PHP (Without Killing Your Server)

Here’s an interesting article that was hanging around in my “to blog” tabs for a while now: How to Read Big Files with PHP (Without Killing Your Server).  I found the title to be slightly misleading, expecting the good old advice of reading and processing files line by line rather than all at once.  But it’s not that.  It’s much better.  It covers some techniques that aren’t that well known to the majority of the PHP developers – generators, streams, and filters.

Strongly recommended read!