Martin Joo Profile picture
Computer Science Simplified newsletter: https://t.co/PFJ3lQJ8oR Blog, DevOps, DDD & performance books: https://t.co/yJPUsoqTLh
3 subscribers
Jan 30 12 tweets 3 min read
Redis is way more than just a cache system - it's a powerful distributed key-value in-memory database with rich features. Let me break down why Redis is awesome and what you can actually build with it.

Keep Reading🧵 Image 2/12 Redis stores everything in memory, making it blazing fast compared to traditional databases like MySQL that need disk reads.

But don't worry - Redis still persists your data using AOL and RDB, so you won't lose anything if you restart.
Jan 16 12 tweets 3 min read
Want to improve your MySQL query performance?

Here's a thread with fundamental tips and techniques to optimize your database queries.

🧵 Keep Reading Image 2/ First tip: Use EXPLAIN to identify inefficient queries.

Watch out for 'ALL' access type. It means full table scan. MySQL scans the entire table. It's like a for loop that iterates through each row,

The 'Index' access type isn't great either, as it reads the whole BTREE index.
Dec 25, 2024 9 tweets 3 min read
🔥 Here are some of the most basic monitoring techniques you can start using immediately:
- Spatie laravel-health
- Error tracking
- Syntethic checks

It takes ~30 minutes to set up these.

🧵 Keep Reading Image Health checks with laravel-health

The package can check:
- CPU load
- Disk space utilization
- Database connectivity
- Redis
- And even query speed Image
Dec 25, 2024 12 tweets 4 min read
💡 This is a DTO or Data Transfer Object from the Domain-Driven Design world.

It helps you:
- Get rid of random arrays
- Structure your unstructured data
- Type-hints everywhere!

🧵 Keep Reading Image 1/11 Life Without DTO

A DTO is used to store and transfer data inside your app. It’s really just a boring PHP class with some read-only properties.

I guess you have seen 500 lines functions from legacy systems where the only argument is an array called $data, like this: Image
Dec 23, 2024 11 tweets 3 min read
🔥 Most applications need to export and import large amounts of data.

It is very easy to:
- Waste lots of memory
- Perform hundreds or thousands of unnecessary DB queries

You can avoid them by learning some pretty simple techniques.

🧵 Keep Reading Image 1/

When it comes to working with larger datasets one of the best you can apply to any problem is chunking. Divide the dataset into smaller chunks and process them. It comes in many different forms.
Dec 6, 2024 15 tweets 4 min read
💡Dealing with statuses and states can be a real headache in larger applications. You can use the state pattern together with transitions and enums.

Some benefits:
- Encapsulation
- SRP
- Small, easy-to-understand classes

🧵Keep Reading Image 1/14 The first step is to create an abstract class or an interface. This is the contract for our states. This is a very simple example.

We have an OrderStatus. The only difference between statuses is that the order can be changed or not: Image
Dec 4, 2024 21 tweets 5 min read
💡How to communicate between microservices?

In the microservice world, we often have 10, 20, or even 50+ services. Communication can be pretty complex, so let’s make it easy!

🧵Keep Reading Image 1/20 In the microservice world, we split the app into different, small services and multiple databases.

We obviously need a way to communicate between these services. There are two main ways of communication:
- Sync
- Async, or event-based
Dec 4, 2024 10 tweets 3 min read
💰 How to handle money in PHP

There are lots of low-quality projects when it comes to dealing with money, numbers, percentages, transactions, and all that financial stuff.

Here are some tips that you can use:
- Value objects
- moneyphp/money
- Model casts

🧵Keep Reading Image 1/9 Cent values

In order to handle money values in a reliable way we need to store them as cent values. Instead of storing $19.99 as 19.99 in the database, we store it as 1999. This way we'll have no problem with decimal points, rounding, multiplying, or dividing numbers.
Nov 30, 2024 9 tweets 3 min read
🔥 Here are some of the most basic monitoring techniques you can start using immediately:
- Spatie laravel-health
- Error tracking
- Syntethic checks

It takes ~30 minutes to set up these.

🧵 Keep Reading Image Health checks with laravel-health

The package can check:
- CPU load
- Disk space utilization
- Database connectivity
- Redis
- And even query speed Image
Nov 28, 2024 24 tweets 7 min read
Here are my favorite 22 Laravel packages📦

I would immediately DIE without them!

🧵Keep Reading 1/ laravel-excel

The single best package to handle Excel exports and imports:

- Exporting collections
- Storing files
- Exporting from a query
- Queue jobs
- And more Image
Nov 27, 2024 11 tweets 3 min read
🔥 Most applications need to export and import large amounts of data.

It is very easy to:
- Waste lots of memory
- Perform hundreds or thousands of unnecessary DB queries

You can avoid them by learning some pretty simple techniques.

🧵 Keep Reading Image 1/

When it comes to working with larger datasets one of the best you can apply to any problem is chunking. Divide the dataset into smaller chunks and process them. It comes in many different forms.
Mar 12, 2024 15 tweets 5 min read
🛠️ How to measure performance in Laravel

There are some pretty simple tools you can start measuring your app's performance with:
- ab
- jmeter
- Inspector
- Telescope

🧵 Keep Reading Image 1/14 Here are some of the most important measures of an API/backend service:
- Throughput: the number of requests the system can handle
- Load time: the amount of time it takes for an HTTP request to respond
- Size: the total size of the HTTP response.
Nov 24, 2023 15 tweets 4 min read
💡How to integrate 3rd parties into your application?

We have to integrate with a ton of 3rd party APIs, and SDKs in every project. You can treat them as mini-applications inside your app.

🧵Keep Reading Image 1/14

Treat your 3rd parties as if they were mini-applications inside your application. They have their own namespaces with their own DTOs service classes and so on. Something like this: Image
Nov 21, 2023 10 tweets 3 min read
💡 If you're running PHP or Laravel apps in production you're probably using nginx and php-fpm.

But do you actually know what these terms mean?
- CGI
- FastCGI
- php-fpm
- How do they connect to nginx?

Let's find out!

🧵 Keep Reading
Image
Image
1/9 CGI

CGI stands for Common Gateway Interface. As the name suggests, it's not a package or library. No, it's an interface, a protocol.

CGI gives us a unified way to run scripts from web servers to generate dynamic content. Image
Sep 20, 2023 11 tweets 4 min read
🔥If you struggle to start with CI/CD pipelines here’s a pretty basic but useful one with:

- phpstan analysis
- phpinsight analysis
- unit tests

🧵Keep Reading
Image
Image
1/10

At the beginning of every GitHub workflow, we need to define what is going to trigger it.

In this case, it’ll run if you push to the main branch or you open a PR to it: Image
Sep 19, 2023 10 tweets 3 min read
💡 If you're running PHP or Laravel apps in production you're probably using nginx and php-fpm.

But do you actually know what these terms mean?
- CGI
- FastCGI
- php-fpm
- How do they connect to nginx?

Let's find out!

🧵 Keep Reading
Image
Image
1/9 CGI

CGI stands for Common Gateway Interface. As the name suggests, it's not a package or library. No, it's an interface, a protocol.

CGI gives us a unified way to run scripts from web servers to generate dynamic content. Image
Sep 11, 2023 18 tweets 6 min read
Here are my favorite 16 Laravel packages📦

I would immediately DIE without them!

🧵Keep Reading 1/17 laravel-excel

The single best package to handle Excel exports and imports:

- Exporting collections
- Storing files
- Exporting from a query
- Queue jobs
- And more Image
Sep 6, 2023 11 tweets 3 min read
🔥If you struggle to start with CI/CD pipelines here’s a pretty basic but useful one with:

- phpstan analysis
- phpinsight analysis
- unit tests

🧵Keep Reading Image 1/10

At the beginning of every GitHub workflow, we need to define what is going to trigger it.

In this case, it’ll run if you push to the main branch or you open a PR to it: Image
Sep 4, 2023 10 tweets 3 min read
💡 If you're running PHP or Laravel apps in production you're probably using nginx and php-fpm.

But do you actually know what these terms mean?
- CGI
- FastCGI
- php-fpm
- How do they connect to nginx?

Let's find out!

🧵 Keep Reading Image 1/9 CGI

CGI stands for Common Gateway Interface. As the name suggests, it's not a package or library. No, it's an interface, a protocol.

CGI gives us a unified way to run scripts from web servers to generate dynamic content. Image
Feb 1, 2023 15 tweets 4 min read
💡How to integrate 3rd parties into your application?

We have to integrate with a ton of 3rd party APIs, and SDKs in every project. You can treat them as mini-applications inside your app.

🧵Keep Reading 1/14

Treat your 3rd parties as if they were mini-applications inside your application. They have their own namespaces with their own DTOs service classes and so on. Something like this:
Jan 25, 2023 14 tweets 4 min read
💡Value Objects Everywhere

I collected some examples of value objects from a financial application I worked on in the past. In a larger, complicated, number-heavy app they really make a big difference!

🧵Keep Reading Image 1/13

In a financial application that deals with publicly traded companies, there are values like these:

- Prices
- Margins
- Ratios
- Market Capitalization
- Numbers in millions

So, instead of using floats and integers, we can create and represent these values as objects.