PHP / Magento Dev Blog

  • Home

Hash table in PHP – in_array vs isset, SplQueue, SplFixedArray

  • 0
Henryk Tews
Tuesday, 08 October 2019 / Published in Algorytmy

A PHP array is one of the most-used data types, but few people think about how it works under the hood. A PHP array is actually a hash table – a data structure that allows O(1) element access. I show how it works, what the practical implications are, and where PHP arrays surprise you with their performance characteristics.

(more…)

PHP 7.4 preview – typed properties, arrow functions, spread in arrays, preloading

  • 0
Henryk Tews
Tuesday, 10 September 2019 / Published in PHP

PHP 7.4 arrives in November 2019 and brings several changes that will have a real impact on everyday code. Typed properties are the headline feature – at last we can declare types directly on class properties. Plus arrow functions, spread in arrays, and the null coalescing assignment operator.

(more…)

Decorator pattern in PHP – composition over inheritance, cached repository example

  • 0
Henryk Tews
Tuesday, 13 August 2019 / Published in Wzorce projektowe

Inheritance is the simplest way to extend a class – but not always the best. When you want to add several independent features to an object, a class hierarchy quickly becomes unreadable. Decorator lets you wrap objects in layers of functionality without modifying the original and without deep inheritance.

(more…)

DI in Magento 2 – container, Virtual Types, Factory, shared/non-shared

  • 0
Henryk Tews
Tuesday, 09 July 2019 / Published in Magento / Adobe Commerce

Dependency Injection in Magento 2 looks like magic at first. You type an interface in the constructor and Magento delivers the right implementation. How does it know what to inject? How does DI compilation work? What are virtual types and what are they for? I break it all down.

(more…)

PHP typing in 7.x, strict_types, PHPStan, preparing for PHP 7.4

  • 0
Henryk Tews
Tuesday, 11 June 2019 / Published in PHP

PHP’s type system evolved gradually from 5.x. PHP 7.x strengthened it significantly – parameter typing, return types, nullable types, and union types on the horizon. PHP 7.4 adds typed properties. A good moment to summarise the state of typing and show best practices worth adopting today.

(more…)

XAMPP vs DDEV vs Warden – full comparison table

  • 0
Henryk Tews
Tuesday, 14 May 2019 / Published in Środowiska

Every PHP developer eventually faces the question: how to set up a local environment? For years XAMPP was the default answer. Today we have far more options – and far more reasons to move away from XAMPP to Docker-based tools. I compare three popular approaches from the perspective of working with PHP and Magento 2.

(more…)

Binary search – O(log n) vs O(n) with comparison table

  • 0
Henryk Tews
Tuesday, 09 April 2019 / Published in Algorytmy

Linear search always works. You go through every element one by one and eventually find what you are looking for. The problem appears with 100,000 elements when you do this in a loop. Binary search solves that problem elegantly – but only if the data is sorted.

(more…)

Observer pattern in PHP and the Magento 2 event system

  • 0
Henryk Tews
Tuesday, 19 March 2019 / Published in Wzorce projektowe

Observer is one of the most commonly used patterns in object-oriented programming, and in the Magento 2 ecosystem it is built into the core of the platform. If you have ever written an event observer in Magento, you have used this pattern – often without realising it.

(more…)

Service Contracts – Data Interfaces and Repository Pattern in Magento 2

  • 0
Henryk Tews
Tuesday, 12 February 2019 / Published in Magento / Adobe Commerce

Directly using Magento 2 models in your own code is a tempting shortcut. The model is right there, it has the method you need, it works. The problem appears when Magento is updated and the internal implementation changes. Service Contracts are Magento’s answer – a stable, public API separated from the implementation.

(more…)

PHP 7.3 – JSON_THROW_ON_ERROR, flexible Heredoc, array_key_first/last

  • 0
Henryk Tews
Tuesday, 08 January 2019 / Published in PHP

PHP 7.3 was officially released in December 2018. Not a revolution, but a few changes have a real impact on everyday code – especially working with JSON, more flexible Heredoc syntax, and a handful of new array functions.

(more…)

  • 17
  • 18
  • 19
  • 20

© 2026 Created by

TOP
Zarządzaj zgodą
Aby zapewnić jak najlepsze wrażenia, korzystamy z technologii, takich jak pliki cookie, do przechowywania i/lub uzyskiwania dostępu do informacji o urządzeniu. Zgoda na te technologie pozwoli nam przetwarzać dane, takie jak zachowanie podczas przeglądania lub unikalne identyfikatory na tej stronie. Brak wyrażenia zgody lub wycofanie zgody może niekorzystnie wpłynąć na niektóre cechy i funkcje.
Funkcjonalne Always active
Przechowywanie lub dostęp do danych technicznych jest ściśle konieczny do uzasadnionego celu umożliwienia korzystania z konkretnej usługi wyraźnie żądanej przez subskrybenta lub użytkownika, lub wyłącznie w celu przeprowadzenia transmisji komunikatu przez sieć łączności elektronicznej.
Preferencje
Przechowywanie lub dostęp techniczny jest niezbędny do uzasadnionego celu przechowywania preferencji, o które nie prosi subskrybent lub użytkownik.
Statystyka
Przechowywanie techniczne lub dostęp, który jest używany wyłącznie do celów statystycznych. Przechowywanie techniczne lub dostęp, który jest używany wyłącznie do anonimowych celów statystycznych. Bez wezwania do sądu, dobrowolnego podporządkowania się dostawcy usług internetowych lub dodatkowych zapisów od strony trzeciej, informacje przechowywane lub pobierane wyłącznie w tym celu zwykle nie mogą być wykorzystywane do identyfikacji użytkownika.
Marketing
Przechowywanie lub dostęp techniczny jest wymagany do tworzenia profili użytkowników w celu wysyłania reklam lub śledzenia użytkownika na stronie internetowej lub na kilku stronach internetowych w podobnych celach marketingowych.
  • Manage options
  • Manage services
  • Manage {vendor_count} vendors
  • Read more about these purposes
Zobacz preferencje
  • {title}
  • {title}
  • {title}