PHP

14 posts
Algorithms

Solution for Hackerrank Problem: Basic Cryptanalysis

There's one programming puzzle I solved many years ago but I still remember it because of the unusual solution. Problem: You have a text encrypted with a simple monoalphabetic substitution cipher. You don't have the key but you have a dictionary. Every word in a text can be found in this dictionary. Find the original text. It can be solved by dynamically generating regular expressions.

PHP

PHP Doesn’t Want You to Do Microservices

As a PHP developer, I should probably rejoice when someone's saying "we do microservices in PHP". I don't. I'm fine with PHP and I like microservices but the combination is just bad. PHP is a tool for solving a narrow range of tasks (i.e. making websites) and if you're trying to do something out of this range (i.e. making microservices) — you're gonna have a bad time.

In this post, I tried to collect all microservice-related PHP problems I saw over the years.

PHP

Finding Overlap Among Groups of Date Ranges

Imagine you have two groups of date ranges and you want to determine whether they overlap.

Nah, let's make it harder. Imagine you have two groups of include date ranges and two groups of exclude date ranges. Your task is to determine, whether there's a date that is present in both include groups and not present in exclude groups. How to do that?

PHP

3 Ways to Make Your API Slow

I had to fix performance issues of one API endpoint. A pretty Symfony endpoint that gathers some data from database, assembling it to some structure and returns it as json.

Performance started being an issue when major part of that "some data" started to be 60000 entities. In worst case response time was almost 20 seconds. "Ok", I thought, "60k is a big enough number to make it slow". But trace showed that retrieving data from DB isn't a slowest part. There were things taking almost 1/3 of request time each. And these things were easy to fix.

PHP

Harmful Technical Interview Questions

Junior dev's life is hard an full of dangers. You come to technical interview and think "at least I'll learn something new from guys that know it better than me". Well, not really. Threre are some things that are ok in interviews and are totally wrong in real life. Here are some examples.

PHP

Why Composer Matters

I've heard about composer long before I started using it. I couldn't understand why it's so much cooler than downloading dependencies manually. I couldn't understand why it's worth running composer install after every code fetch.

This article is for guys like me in the past. If you're already using composer you can stop reading.

PHP

Creating an API Documentation in Swagger Using YAML

UPD: I wrote this for swagger v1.2. Stuff has changed since then. Now swagger supports single-file YAML specifications, so making them is easier now. What a time to be alive!

A few days ago was the first time I created a REST API documentation. This is the report on how I did it.