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
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.
2/9 Value objects
The other thing we can do is to use value objects instead of treating them as float numbers in PHP. So instead of this:
🔥 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
Health checks with laravel-health
The package can check:
- CPU load
- Disk space utilization
- Database connectivity
- Redis
- And even query speed
The example contains pre-built checks. For instance, it notifies you if the average CPU load is higher than 2.5 in the last 5 minutes or 2 in the previous 15 minutes.
It also notifies you if the used disk space is more than 70%
The single best package to handle Excel exports and imports:
- Exporting collections
- Storing files
- Exporting from a query
- Queue jobs
- And more
2/ laravel-health
This amazing Spatie package can monitor the health of your application and server. It sends you notifications if something's wrong. For example:
- CPU load
- Used disk space
- Database connections
- Redis
- and more
🔥 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
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.
2/ Let's start with a simple CSV or XLS export since it's a common feature in many applications. laravel-excel is a pretty good package that you can use.
There are some pretty simple tools you can start measuring your app's performance with:
- ab
- jmeter
- Inspector
- Telescope
🧵 Keep Reading
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.
2/14 ...measures of an API/backend service
- Server uptime: the duration of time the server is up and running
- CPU usage: the amount of CPU your system needs to run. It is usually expressed as load average
- Memory usage: the amount of memory your system uses
💡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:
2/14
In the Services folder, I create a new folder for each 3rd party and treat it like it is a mini-application inside my app.