They say you should understand floating-point precision by 35.0000000000014. This post is here to help you: it discusses how floats are (im)precise and why, demonstrates the problems you inevitably encounter when doing math with floats, and presents ways to prevent those problems by using more proper data types and structures.
There's a new buzzword on the PHP block: frameworkless. The activities of PHP communities last year made it possible to build robust applications, uniquely composed of little bits, without relying on a big framework. Let's find out how they work and if it's a good approach.
As the business requirements grow, so does the list of dependencies. Managers ask for a new feature, you just composer-require this thing and that other thing, and wire it into the application. But how do you keep track of new features in the dependencies? Or bugfixes? Or, most importantly, security patches?!
Almost every application needs to work with time: if not for some greater purpose like expiring access credentials, entities usually store information about when they were created or generally when something happened. Telling time is indeed a crucial responsibility, and being able to rely on the mechanism across the whole codebase is really important. But it can get problematic.
I've had a really productive couple of weeks and (mostly) weekends recently. I've worked extensively on one of my side projects using modern JS stack including Webpack, faced issues here and there, and found a way to solve them. In the end, I proudly announce three new open-source packages: a modern AJAX library for Nette Framework, Neon loader for Webpack, and a library integrating the Webpack build process into Nette-powered applications.
Unit testing a class that uses Nette's cache can be a pain in the you-know-what. I've found myself writing a very simple cache factory to solve this and make testing classes depending on cache a pleasing experience, so I've decided to make an extension out of it.
Listing data is essentially the most crucial part of websites. Be it products, articles, photos or whatnots, we usually need to provide the user the way to filter and/or sort the data by some preset parameters. I'll show you how to encapsulate such filtering within an object, build a user interface (in other words, a form) upon it, and use it with Kdyby/Doctrine's query objects to actually filter the data on the database level.
Last December, I implemented smart forms via Kdyby/DoctrineForms on this blog. Since the documentation of the package seems to be quite lacking in its scope, I decided to share with you how to overcome the pitfalls I had encountered and make it work.
In order for components in Nette to be as reusable as possible, it is necessary to decouple them from presenters. The cleanest way out of this is to invert the dependency. After all, it's the presenter that requires the component, not vice versa.
The need for authentication mechanisms that provide more security has been rising during the recent years. Google has ventured into this field with their Authenticator application which is now used not only by Google itself, but also other big players like Github or Dropbox. And you know what? It's not really that difficult to join this elite group. I'm going to show you how.