Book cover

My book “Mastering PDF with PHP” is out now on Leanpub!

Learn how to create, read and edit PDF files in your PHP applications!

  • 8 Programming Myths That Impede Your Career

    During 14 years of my software development career, I've seen - and was a victim of - numerous myths and fads of the IT industry. Common beliefs and misconceptions often impeded my career because I wasted energy on activities that did not bring the expected benefits. Here's my guide on how to avoid fighting for a lost cause as a software developer.
  • How to set a font in a PDF document

    In this article, you will learn how to set custom fonts when converting HTML to PDF. We will cover several conversion tools, including Headless Chrome, WeasyPrint, Prince, wkhtmltopdf, TCPDF, mPDF and Dompdf.
  • How to encrypt a PDF document in PHP

    If your business uses Portable Document Format to send private and sensitive data like bank documents, you might need to use password protection. In this article you’ll see how to encrypt PDFs with tools available for PHP.

  • Executing shell commands from a PHP script

    If you need to call an external program from your PHP script, for example to create a PDF file or convert images, there are several ways to do that. I strongly recommend using the Symfony Process Component. It wraps around native PHP functions like proc_open() and it provides extra level of security. It is also very convenient because of an object-oriented interface.
  • Too much REST will harm you: don’t blindly follow it!

    REST, or Representational State Transfer, is a set of web architecture best practices. Perhaps it is best known for associating resources and actions in order to create clean API interfaces. Although REST works perfectly fine in most situations, I will show you how it can cause security issues where security matters most: the payment industry.
  • Picking a PHP tool to read and manipulate PDF files

    Today we will browse possibilities to read and edit existing PDF files.
  • I moved my WordPress blog to Jekyll. Here's why and how

    I remember the times around 2000 when most websites were static. We edited them locally on our computers and then uploaded to an FTP server. There was plenty of free hosting services. Building your own site was very easy.

  • All you need to know about Java’s BigDecimal

    Popular programming languages do not natively support decimal numbers. This is because CPUs operate on binary numbers. Even though there is a new IEEE standard for decimal floating point types, CPUs still don’t support it fully. So every time we see a notation like 0.1 in the code, it’s not what it seems. Our calculations might be inaccurate.

  • PHP: How to take a screenshot of a PDF page

    If your application allows uploading PDF files, it’s likely that you need to prepare screenshots or thumbnails for these documents – at least the first page.
  • Secure generation of random IDs and passwords in Java

    The Apache Commons Lang library has a handy set of random string generators, enclosed inside the RandomStringUtils class. However, these are not cryptographically secure generators by default, which can trigger warnings in platforms like Veracode (for example CWE-331: Insufficient Entropy).

  • Sending monetary amounts over network

    If you write any application that operates on money – even a simple web shop, sooner or later you will have to send monetary amounts through API calls, SQL queries, CSV downloads, and so on. Let’s see how to avoid common mistakes which could destroy your business!

  • Formatting monetary amounts with Java Money

    Java is very often used to develop big financial systems, yet still the JDK has little or no support for monetary arithmetics, currency conversion, formatting money for different locales etc. There’s only a Currency class which serves as a list of ISO 4217 currencies.

  • Using your own currency in MoneyPHP

    I have this talk about the MoneyPHP library and handling currencies in general. I often get a question: is it possible to define custom currencies in MoneyPHP? A possible use case would be loyalty cards for example, with their own scoring system.

  • Doing Java the bad way: loose typing

    In the late 90s, people loved PHP because it was so easy to use. And one of the reasons for that was loose typing. You could quickly send any data to the browser without caring about data types.

  • Why you should disable wildcard imports in IntelliJ IDEA

    The default behavior of IntelliJ IDEA is to replace multiple class imports from a package with an asterisk. At my team, we decided to avoid that behavior. Why?
  • Why I didn’t end up being a database engineer

    Once upon a time, looking for new career opportunities, I considered becoming a database engineer or architect. I was pretty successful in optimizing MySQL databases growing up to 65 GB. I liked it. However I noticed almost no one was hiring MySQL database engineers – it’s too simple. Real challenges await those familiar with Oracle and big finance systems, aviation etc. So, I bought a thick book about Oracle and… never used it.

  • Is Portable Document Format obsolete?

    I spent two years on a project which aimed to create highly sophisticated PDF reports for teachers. These automatically generated reports contained bar chars, pie charts, line charts, a lot of tables and everything else. It worked: end users were very happy about the new reports system. But still, something keeps bothering me.

  • There are some limits to the YAGNI principle

    Have you heard of YAGNI? The acronym stands for “You Ain’t Gonna Need It“. The original meaning, as Extreme Programming guru Ron Jeffries said, was to “implement things when you actually need them, never when you just foresee that you need them”. But how did this principle evolve over time?

  • Defensive coding: Null-safe string comparisons

    One of the most valuable tips I received why having my Java code reviewed was to change this code:

  • Defensive coding: Make local objects final

    In the very first article on defensive coding we talked about avoiding mutability.

  • Defensive coding: Final properties and proper autowiring in Spring

    Dependencies should not be mutable. When using @Autowired on properties, you cannot use final because your compiler will complain that the objects are not initialized. The compiler doesn’t know the Spring magic behind instantation of these objects. This means that someone can accidentally overwrite the property.
  • Defensive coding: Avoiding mutability and side effects

    Are you tired of fixing the same bugs on and on in a huge system developed by a multitude of developers? I guess it’s time to introduce some practices of Defensive Programming. It is an approach to improve software quality by reducing number of possible bugs and mistakes and making the code more predictable and comprehensible.

  • How I optimized a process from 35 to 5 hours

    Most of my day job isn’t fascinating. Yet another controller, service, test, and so on. I spent a lof of time doing repetitive tasks and slowly gaining more knowledge about the system I’m working on. However, having slow and steady pace can eventually reward you with an opportunity to make a really great improvement. It happened to me, twice.

  • Mixing office and remote workers in one organization

    Remote work is challenging. People working remotely need perfect communication skills and discipline because no one is watching over their shoulder. However, the real struggle starts when we try to combine office and remote employees. What problems are we going to face and how can we improve the situation?

  • Offboarding: How to quit the job gracefully

    Recently I shared my thoughts on preparing an efficient onboarding process. Unfortunately, sooner or later people quit. This is also something our dev team should prepare for.

  • 6 Steps to Effective Developer’s Onboarding

    Who’s responsible for building a development team? A team leader? Scrum master? Senior engineers? I strongly believe that every team member contributes to its work culture. I also believe that one of the best benchmarks of a team’s performance is the way new developers are introduced.

  • Picking a PHP tool to generate PDFs (2024 update)

    I spent a lot of time working with different tools to generate PDF files, mainly invoices and reports. Some of these documents were really sophisticated, including multi-page tables, colorful charts, headers and footers. I tried generating documents by hand and converting HTML to PDF, or even LaTeX to PDF.
  • Testing PDF documents

    I’ve been wondering for some time if PDF is still a valid format. It’s “portable”, of course, but not in today’s meaning – it’s clearly not responsive. Like a fixed piece of paper transformed into a file. However, PDF still has many important use cases like storing invoices, reports or tickets. I spent a couple of years working on sophisticated PDF reports, and this year I even tried to test a process of generating invoices in some ad exchange system. I really wanted this system to be rock solid.

  • Java: Integer or int?

    When I first saw primitive types like int or boolean mixed up with classes, I was very tempted to convert all primitives into Integer, Boolean and so on to maintain a clear coding style. But reading articles on the Internet and IntelliJ hints stopped me from doing such a stupid thing.

  • NPE: Converting a list of objects to a map

    Like every Java developer, I had a fair amount of Null Pointer Exceptions in my career. That’s why I decided to describe real-world examples I had to fix.

  • Do we still need recruitment agencies?

    As a candidate looking for jobs, I’ve never cooperated with any recruitment agencies. But as a senior developer responsible for tech interviews, I was forced to work with some HR companies and I had some really weird situations because of that.
  • Is a managing position good for me?

    When you’re an engineer, sometimes you might get an offer to take over management duties. It might be for example leading smaller projects, being a scrum master or leading a whole team of developers. When to consider such options and how to get prepared for new challenges?

  • When your SQL database is missing foreign keys

    …then sooner or later, you’re going to have a bad time. Bugs in your app or users’ recklessness will cause your database to be inconsistent.

  • 6 Things That Can Ruin Corporate Trainings

    How to gloriously waste three days of a 10-person development team? Send them to a wrong training led by a wrong person. As a team leader I made this mistake twice. There will be no third time.

  • Why we adopted a coding standard and how we enforce it

    Everyone might have their own code formatting preferences. Problems arise when a team consisting of a couple of individuals work on a common code base and every developer has different preferences. It’s hard to maintain pull requests in this situation.

  • Learn how to count money… or you will lose it

    It sounds weird when I get a ticket like this: when I set the price to $4.20 everything’s fine; but I cannot set the price to $4.10 because the system shows $4.09. I did some research and discovered that a user entered the price in dollars and then we converted it to cents to store in the database as an integer. That’s where the mistake was made.
  • How unit tests help changing existing code

    You should have some tests. Why? Because developers are afraid to make changes in a code they don’t understand. This is a common problem not only with fresh employees, but with everyone who stands in front of a huge, complex, legacy system. They are afraid to add a new if not to break the other ones. They are afraid to erase code that seems obsolete.

  • How legacy code is made – part 2

    In the previous post, I told you how tight coupling causes systems to be hard to maintain and expand with new features. Today I’m going to show you how developers often take shortcuts which then add up to the technical debt.

  • How a legacy code is made

    I received an apparently easy task to do. It should take maybe 15 minutes. Or maybe I should not even do it at all. Salespeople should have a reporting feature for that. However, it turned out that a mechanism to fetch products with prices was strictly tangled with the way these items were presented in the shop.

subscribe via RSS