Because libraries solve some problems in a specific area and allow making something easier, we use tons of libraries/frameworks and internal project components written by us… in order to make an application easier. However, this situation brings other complexities that we need to take care of, like relations between the components. In this article, I would like to mention how to use the technique as known as Dependency Injection in a TypeScript project.
As you know, Github allows us to execute continuous integration pipelines through Actions easily. Today, we are going to see how to deploy your code directly from Github to your server by using Ansible, Docker, and Github Actions.
Ansible is an IT automation tool that communicates to servers via SSH protocol without using any agent mechanism. It allows you to execute commands on remote servers or transferring files to servers from the system where you run the Ansible playbook. So the key problem is being able to access the remote servers from a public system like Github.
We can execute the Ansible playbooks in a docker container through Github Actions by using a specific private key that eligible to access the remote servers. …
In a development environment, one of the biggest problems is finding the occurred problem between the services and it needs that you need to check too many log files in order to find the root cause. You may need to check the web, application, database, cache… etc. server logs even in a simple monolith application.
Today, we’ll see how to aggregate the application logs in one single place that we can follow easily through Docker Compose, Graylog, and Elasticsearch.
As a sample application, I’ve chosen Symfony Demo project written in PHP. It requires PHP, Nginx and MYSQL instances to work. Since we need some customization on PHP-PFM and Nginx configurations, we’ll create separate custom Dockerfile(s) for both services. …
You may have an application that depends on one or more services that start slowly. So, you must put some extra controls before starting the application, in order to prevent startup errors and run the application smoothly.
Let’s take the following example:
We have an application that directly dependent on RabbitMQ and MySQL services and it connects to both services in application startup. However, the worker container constantly fails because it starts before the other services.
Let’s start first by defining the dependencies between the services in the docker-compose.yaml
to start the worker container after RabbitMQ and MySQL containers.
Sometimes, a message consumer might be failed because of connection issues or other logical reasons. In this case, the application should handle the fail scenario properly and retry the failed message several times based on some rules.
Today, we are gonna see how to retry a failed message in a Symfony application through Messenger Component by referencing the previous post:
Messenger Component, retries a failed message through the dead letter
feature of RabbitMQ in case of RabbitMQ usage. It tries by default 3 times, with 1000 ms delay, and multiplies the duration by 2 in each try.
Most of the API’s requires some authentication mechanisms in order to identify the user and allows to access some resources based on the authorization rules. Although the way of the identity declaration changes, most of the authentication mechanisms requires to perform a request to an authentication endpoint in order to obtain an identifier before going to the actual resource. However, you can’t use that identifier forever.
If you take all this information into consideration, to make even a simple API call requires the following flow:
As you know, message-based asynchronous flows are a significant part of the web applications that allow scaling backend processes. You can move all the long time processes to asynchronous flow and make your user interface faster as much as you could.
Today, we’re gonna see how to use RabbitMQ
with Symfony
through Messenger
component with a simple use case.
I strongly recommend to check out the following document in order to understand the message bus concept and the fundamentals of each component in Messenger:
The business needs changes and sometimes even you might not reach the people’s speed. No matter how reusable code that you’ve written; all your changes may become garbage in a few days with new business needs. Until MariaBundle.
The Bundle mechanism is a way to make reusable software packages for the PHP applications that use Symfony. It’s probable that a bundle can have own dependencies and needs to be tracking under separate version control. Although Symfony bundles are independent packages, you might still need some application dependencies during the development period in order to check the integrity or simply run the code, besides the tests. So, in this article, I’m gonna try to explain step by step, how to prepare an efficient development environment in order to develop a Symfony bundle.
Docker is the tool that gonna help us to run the code for a specific PHP version. So, let’s start by creating a new Dockerfile
with the following content. …
As you know, aws-sdk-mock
is an awesome library that allows you to mock aws
service calls in the tests. However, you can’t mock the service instances by aws-sdk-mock
in some cases like if you instantiated the instances in the global scope and trying to mock/restore before/after each test cases. Today we will try to find a way to mock and restore the service instances by using jest and aws-sdk-mock
in order to write a proper test.
Before starting, there two things you need to know;
beforeEach()
and afterEach()
methods as long as they are instantiated in the global scope. …About