---
title: "Count Revisions"
url: "https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/counting"
version: "6.2"
language: "php"
---

# Count Revisions

> Client language: PHP. Also available for [C#](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/counting.md), [Python](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/counting.python.md), [Node.js](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/counting.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - You can get the number of revisions a document has by using the session `advanced` method `getCountFor`.
>
> - In this page:
>   - [Get revisions count](#get-revisions-count)
>   - [syntax](#syntax)

## Get revisions count

```php
// Get the number of revisions for document 'companies/1-A"
$revisionsCount = $session->advanced()->revisions()->getCountFor("companies/1-A");
```

## Syntax

```php
function getCountFor(?string $id): int;
```

| Parameter | Type | Description |
| - | - | - |
| **id** | `string` | The ID of the document that revisions are counted for |

| Return value | |
| - | - |
| `int` | The number of revisions for the specified document |

## See also

- [Document Revisions Overview](https://docs.ravendb.net/6.2/document-extensions/revisions/overview.md)
- [Revert Revisions](https://docs.ravendb.net/6.2/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.md)
- [Revisions and Other Features](https://docs.ravendb.net/6.2/document-extensions/revisions/revisions-and-other-features.php.md)
- [Revisions: API Overview](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/overview.php.md)
- [Operations: Configuring Revisions](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/operations/configure-revisions.php.md)
- [Session: Loading Revisions](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/loading.php.md)
- [Session: Including Revisions](https://docs.ravendb.net/6.2/document-extensions/revisions/client-api/session/including.php.md)
- [Settings: Document Revisions](https://docs.ravendb.net/6.2/studio/database/settings/document-revisions.md)
- [Document Extensions: Revisions](https://docs.ravendb.net/6.2/studio/database/settings/document-revisions.md)
