Writing a Telegram Bot Step by Step

Hi! This week I interacted myself and wrote my own telegram bot. It’s a brief instruction how to make this shit working.
Firstly - please care about valid SSL certificate. Yes, Telegram requires a valid SSL certificate for webhooks. Yes, for staging server too. If you found a way to avoid it - please tell me, it will make me happy and this post more useful.

I was thinking bot creation process is something complicated but fortunately, I had mistaken. Bot workflow if pretty simple, so I will separate this flow into section

  1. Ask @BotFather for a new bot. (It’s not a joke)
  2. Configure name and avatar of your bot
  3. Doing main steps to make backend working
  4. Writing commands. Why it’s a good idea to separate commands in separate entity.
  5. Test your bot

    Read More

How to Bind Object Scope to a Closure and Invoke It in PHP7

Closures isn’t a popular feature in php community and it’s makes me sad, because closures is an useful option makes possible to increase you performance.

Firstly let’s explain me how closures basically works in PHP. The closure is an unnamed function is helpful as callback parameter.

So here I show this on example:

$sampleArray = ['1', '2', '3'];

$data = array_walk($sampleArray, function($data) {
	echo $data * 2, PHP_EOL;

We will see ‘2 4 6’ on the screen. You can make a callback predefined:

Read More

'Strict Mode' in PHP7 Is Not Strict Enough?

Recently I heard that in PHP7 we can pass a string as integer and get result in strict mode. Let’s try it together. Pay attention, behavior we check is already described in the documentation. It’s all being ‘not a bug, just a feature’. So, let’s go. As you know, now we can define strict mode using next instruction:


So, try to write simple piece of code like this:


function typesCheck(int $number) {
	echo $number;
	return $number;


And now we will see ‘3’ on our screen. It’s absolutely predictable behavior. Now we will try to pass a wrong argument:

Read More