Difference between entities and value objects from philosophy perspective

Imagine a wooden ship. It's a quite famous ship - Theseus himself used it to return to Athens from Crete. After that Athenians tried to preserve it by replacing decayed planks with new ones. Many years passed and now we can say for sure that every part of the ship was replaced at least once. Is it still the same ship?

Read full post »

Published at 2017-11-10

Tags: ddd, philosophy


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.

Read full post »

Published at 2017-10-11

Tags: api, php, symfony, doctrine


How to make aliases for Symfony form fields

Imagine you want to rename form parameter but you also want it to accept old parameter name in requests to preserve backwards compatibility. Here's how you do it.

Read full post »

Published at 2017-10-02

Tags: php, symfony, symfony forms


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.

Read full post »

Published at 2016-06-14

Tags: php, javascript, hr


Imagick resize filters comparison

So you want to shrink images with php and imagemagick. Here's samples of all filters so you can select the one you like most.

Read full post »

Published at 2015-09-11

Tags: php, imagemagick, thumbs


Nicolas Cage as default avatar

No one asked me about this for months. And now it's done. Gravacage has it's own documented php library and site.

Read full post »

Published at 2015-04-01

Tags: my library, ui


How to attach composer to Yii project

Sometimes I'm asked how to do this. It's boring to say that again and again so here's the instruction.

Read full post »

Published at 2014-09-29

Tags: composer, php, yii


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.

Read full post »

Published at 2014-08-26

Tags: composer, php


Font Awesome icons for common buttons

Font Awesone is cool but it is sometomes hard to find the icon you really need because you forgot how it's called. And you have to look at every icon to find something you need.

Here's the names of icons for common buttons and operations.

Read full post »

Published at 2014-07-07

Tags: font awesome


Yii 1.1 does not support object cloning

You better watch out
You better not cry
You better not clone Yii objects
I'm telling you why
Object cloning is coming to town not supported in Yii 1.1.

Read full post »

Published at 2014-06-26

Tags: yii, bugs


urmaul/url to make urls absolute and stuff

Copy-pasting two functions between projects is boring so I've created a GIANT COMPOSER PACKAGE with class with these two functions. It can convert relative urls to absolute and to add get parameters to urls. It's called urmaul/url.

Published at 2014-06-04

Tags: my library, php, urls


Creating an API documentation in Swagger using YAML

UPD: I wrote this for swagger v1.2. Stuff changed since then. Now swagger allows you using yaml and it wants just one file so making specs is easier now. What a time to be alive!

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

Read full post »

Published at 2014-06-02

Tags: rest, api, yii, php, documentation, swagger, yaml, json


Mysql formats for some data types

Proper mysql column types for things like emails, coorditates, password hashes and stuff like that.

Read full post »

Published at 2014-05-23

Tags: mysql


Free bootstrap admin themes

You don't really care how admin panel looks like, yeah?

Bootstrap allows you to create not-so-ugly UI elements but you still have to assemble them into templates.

But there's some free admin themes for bootstrap that are already designed.

Read full post »

Published at 2014-05-22

Tags: links, bootstrap, ui


Inline PDF in html page

A piece of php code for inserting pdf files into html pages.

Read full post »

Published at 2014-05-21

Tags: html, pdf, php


Cartograpther - a PHP component to generate sitemaps

Some info about a good tool for creating sitemap.xml files and some tips about how to use it.

Read full post »

Published at 2014-05-15

Tags: seo, php


Disabling autocomplete

Browsers are so smart they are trying to fill forms for you. And sometimes this is bad.

Html5 provides an attribute autocomplete="on|off" to prefent browsers filling fields for you. And you should add autocomplete="off" to inputs in cases like these:

  • "Set password", "Change password" and "Retype password" fields.
  • Captcha field.
  • Credit card number.

Sometimes you need to do it for security reasons. Sometimes it just makes your forms more comfortable.

Published at 2014-05-13

Tags: html5, security, usability, ui