Browse Category: PHP

PHP’s Array vs Python’s List

To begin with, I have never ever written a useful program that didn’t involve some kind of dynamic in-memory storage. Luckily, I do most of the work with high-level programming languages, so data structures like doubly linked list are long gone. 🙂

I will show you differences and similarities of PHP’s array and Python’s list for cases that appear everyday in my life. Prepare for reading some code and let’s go!

Continue Reading

Is it worth to set Eloquent fields explicitly?

You know, I love Eloquent so much! It provides very elegant way to link you database to models. And it does a lot of things for you too, for example:

  • guessing table name by class name;
  • guessing which field should be used for foreign keys.

Have you ever wondered, how much overhead do these things create? I did. And I figured it out with table name case (I guess should be similar with foreign key column guessing. Take a look at my experiment!

TL;DR: It is worth.

Continue Reading

Hidden features of Laravel Authentication

Laravel provides excellent authentication mechanism. Have you ever wondered how it works? Documentation states, that it is very flexible, but does not show flexibility of it.

I will show you some features, that I personally love, and how I managed to find those, so you can start your own journey. Lets begin!

Continue Reading

How to receive data from API using Guzzle

Times have come, when applications are no longer isolated, so we, developers, have to adapt. RESTful web services are now getting more and more attention, but, before diving into specifics of REST, you should know how to access simple API and how to receive data from it. Just read and you will see. 🙂

In old times, PHP developers (me included) were using cURL library, but it is a bit pain in the ass. Better, more readable and modern way is to use some library .. and I present you – Guzzle. What it does, you might ask. It just abstracts HTTP protocol. You don’t have to worry about losing pointer with cURL or some other low-level mistakes. Give me a few minutes and I will show you how to do it! Continue Reading