Let’s make a Telegram Bot with PHP

I spend a few days creating a Telegram bot for my SaaS. It serves as a convenient way for my users to enter data. The bot isn’t smart at all, but at its core is a regex pattern matcher which allows entering various health-related data points.

While the Telegram docs try to give you an easy start, I found them lacking. With this article, I want to fill some gaps.

Continue reading Let’s make a Telegram Bot with PHP

Value Objects in Laravel 5 with Eloquent Done Right

Update April 25th, 2016: I don’t use Value Objects in Laravel anymore. Here’s why.

One idea of Value Objects is to restrict what a programmer can do within the model. For example, an EmailAddress value object cannot be set to an invalid email address.

The advantage is: Validation and consistency of the domain model.

With Laravel however, there are a few things to think about and it took me a while to figure out a good solution.

tl;dr:

  • Use a Mutator to enforce the type of a Value Object
  • Store your Value Object as native value in your Eloquent model
  • Use an Accessor to create a Value Object from the native value
  • Implement __toString() in your Value Object to allow toArray()
  • Use the JsonSerializable interface to allow toJson() conversion
  • Plus: Do all of this automatically without Mutators and Accessors

Continue reading Value Objects in Laravel 5 with Eloquent Done Right

Server Hangs or Crashes with large Piwik Installation

Update 01.06.2015: Issue still remains. The suggested fix in this post didn’t work for me.

I have a dedicated Linux server (Debian) that runs Piwik. It’s a fairly standard installation of the LAMP stack. My Piwik server tracks visitors on 5–6 websites and one of them is fairly large with thousands of visitors per day. In recent weeks, my Piwik server would sometimes just hang. Responses weren’t sent and thus, I have gaps in my visitors graph, which is pretty annoying.
Continue reading Server Hangs or Crashes with large Piwik Installation