In Drupal 8 for querying entities, there is no more EntityFieldQuery like Drupal 7, but there’s an entityQuery.
The entityQuery() is a static method on the \Drupal namespace, is a shortcut for doing so using the entity.query service.
The most important method in the
EntityQuery class is the
$bundle = ‘article’;
$query = \Drupal::entityQuery(‘node’);
$entity_ids = $query->execute();
Conditions allow us to limit our query in specific ways. It’s having following parameters :-
function condition($field, $value = NULL, $operator = NULL, $langcode = NULL)
Using functions like conditions, range gives us liberty to…
Drupal Database API is an abstraction layer built upon PHP’s PDO (PHP Data Objects) database API. The database abstraction layer also provides a structured way to construct complex queries and it protects the database by using good security practices.
Because different databases require different sorts of interaction, the Drupal database layer requires a driver for each database type.
Database connection objects
The examples here all use functions like db_select() and db_query(), which can be called from any Drupal method or function code. In some classes, you may already have a database connection object in a member variable, or it may be…
Drupal Console is a very powerful CLI tool. As soon as you’ll start using it, you will start loving it and being a developer will ease your life. It will provide you more time to think about logics :).
So let’s see how to create a module using CLI.
To check how to setup Drupal console
To create a custom module, just open your terminal and go to your project root. As I have set up a drupal console within my project using command —
composer require drupal/console
So type a command -
Drupal Console is a command-line interface (CLI) tool to generate boilerplate code. It’s a powerful tool for a developer who is writing code for Drupal.
To install CLI there are two options. Either you can install globally or you can install within your project in the vendor directory. I prefer to install within the vendor because it’s easy to maintain versions wrt to Drupal version(8 or 9).
To install globally in mac or Linux-
curl https://drupalconsole.com/installer -L -o drupal.phar
mv drupal.phar /usr/local/bin/drupal
chmod +x /usr/local/bin/drupal
If you don’t have curl-
php -r “readfile(‘https://drupalconsole.com/installer');" > drupal.phar
mv drupal.phar …
First of all Drupal 9 is not a reinvention of Drupal. Drupal 9, contains all the features of Drupal 8, but with deprecated APIs removed, and some 3rd-party libraries updated. There are only two key differences in Drupal 9:
Other than these two things, Drupal 8.9 has most of the changes that Drupal 9 does but retains backward compatibility layers added through Drupal 8’s release and is a good choice to update to first if you have an existing Drupal…
Recently I got certified as an AWS Certified Solutions Architect — Associate. I was preparing for this exam for the last two to three months. So I thought to share my experience and preparation journey.
It’s not about the exam tips but yes after reading it might help you plan your preparation for the exam.
First of all, let me help you to understand about my work experience with AWS. Mostly I have a web development experience and I used AWS for around three to four applications. Mostly EC2, S3, Mysql, Cloudfront and DynamoDB.
One thing is sure, Either you…
What is Eureka?
Eureka is a REST (Representational State Transfer) based service that is primarily used in the AWS cloud for locating services for the purpose of load balancing and failover of middle-tier servers. We call this service, the Eureka Server. Eureka also comes with a Java-based client component, the Eureka Client, which makes interactions with the service much easier. The client also has a built-in load balancer that does basic round-robin load balancing.
At Netflix, a much more sophisticated load balancer wraps Eureka to provide weighted load balancing based on several factors like traffic, resource usage, error…
Programmer | Thinker | Open Source | Tech Mantra