<commit_before>---
title: Tequila MongoDB PHP Library
layout: post
---

# Getting started

This high-level MongoDB driver was created to replace 
[Legacy MongoDB PHP Driver](https://github.com/mongodb/mongo-php-driver-legacy),
i.e. `pecl/mongo` PHP extension, which for now is deprecated and does not work with PHP 7.
This library is based on the new official low-level [MongoDB PHP Driver](https://github.com/mongodb/mongo-php-driver),
follows [MongoDB Driver Specifications](https://github.com/mongodb/specifications) 
and defines abstractions like `Client`, `Database`, `Collection` etc.

## Installation

Since this library is based on a new low-level driver, it requires this driver to be installed:

```bash
sudo pecl install mongodb
```

The library itself should be installed by Composer:

```bash
composer require tequila/mongodb-php-lib
```

## Usage
First, let's see what was changed in a new driver. 
All new drivers for MongoDB should follow [MongoDB Driver Specifications](https://github.com/mongodb/specifications).
By following this specifications, this library introduces different changes beside the API
of the legacy driver.
Below there are examples of how to do common tasks using this driver in comparison with te API of the legacy driver:<commit_msg>Front matter include in docs/index.md<commit_after>---
title: Tequila MongoDB PHP Library
---

# Getting started

This high-level MongoDB driver was created to replace 
[Legacy MongoDB PHP Driver](https://github.com/mongodb/mongo-php-driver-legacy),
i.e. `pecl/mongo` PHP extension, which for now is deprecated and does not work with PHP 7.
This library is based on the new official low-level [MongoDB PHP Driver](https://github.com/mongodb/mongo-php-driver),
follows [MongoDB Driver Specifications](https://github.com/mongodb/specifications) 
and defines abstractions like `Client`, `Database`, `Collection` etc.

## Installation

Since this library is based on a new low-level driver, it requires this driver to be installed:

```bash
sudo pecl install mongodb
```

The library itself should be installed by Composer:

```bash
composer require tequila/mongodb-php-lib
```

## Usage
First, let's see what was changed in a new driver. 
All new drivers for MongoDB should follow [MongoDB Driver Specifications](https://github.com/mongodb/specifications).
By following this specifications, this library introduces different changes beside the API
of the legacy driver.
Below there are examples of how to do common tasks using this driver in comparison with te API of the legacy driver:
{'fraction_non_alphanumeric': 0.08414872798434442, 'fraction_numerical': 0.0007827788649706458, 'mean_word_length': 4.8223234624145785, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '52311', 'n_tokens_mistral': 738, 'n_tokens_neox': 688, 'n_words': 313}