The Best Databases for PHP

or, The Most Popular Databases for PHP in 2021

rachelle palmer
2 min readOct 13, 2022
php logo, php elephant

One of the most common questions for new PHP developers is which database to use. You can find a lot of resources on this topic (like this one, this one, or this one) — but all of these are old articles. Most don’t include mentions of newer, modern databases. I have no idea of what’s popular vs just one random person on the internet’s opinion.

I like making decisions using data. 18,130 PHP developers replied to the StackOverflow 2021 survey, which is a fairly large sample. Let’s see what databases they are using.

MySQL — 82.77%

That’s right, 82.77% of PHP developers use MySQL. It’s supported by the major frameworks, there are tons of tutorials, and almost every ‘get started’ course uses MySQL for their examples, so this figure totally makes sense.

SQLite, PostgreSQL, and MariaDB — 35 to 38%

For each of these SQL databases, there are fairly significant numbers of developers who have used them. MariaDB is most likely made popular by its inclusion in the XAMPP software bundle, as it is much less popular with other programming languages (just 14% of SO developers have ever used MariaDB, compared to 38% of PHP developers). Similarly, 37% of PHP developers use SQLite, but only 27% of all developers have used SQLite.

MongoDB — 31%

Leading the NoSQL databases by a large margin is MongoDB. MongoDB works well with Symfony and Laravel, and is a scalable database best suited to PHP developers working with flexible schemas and documents. Other document and NoSQL databases don’t even come close: only 2.47% of PHP developers use Cassandra, and less than 2% use Couchbase.

Redis — 22.84%

The #6 Ranked key value store garners almost 1/4 of PHP developers, which is pretty good. This is honestly worse than I expected, since Redis is powerful, scalable, and works well for its use case.

What Database do PHP developers want?

The top three most desired databases for PHP developers are MySQL, MongoDB, and PostgreSQL. About 25% of PHP developers don’t care/didn’t specify which database they prefer.

What Database Not to Use with PHP

Technically you could always use any database you want. But PHP developers don’t tend to use DB2 (2.0% of devs), Cassandra (2.4%), Couchbase (1.92%), DynamoDB (5.8%).

I never make decisions based on one data point and you shouldn’t either. I also recommend the DB Engines rankings or TopDB Database Index. All of this information can help your team make the right decision about which database to use for PHP.

P.S. Here’s the link to the SO2021 survey raw data.

--

--

rachelle palmer

Data Informed Decision Maker. Product Leader@MongoDB. Mostly human.