# Cloud Firestore Client - Class FieldPath (2.2.0-RC1)

2.2.0-RC1 2.1.0 (latest) 2.0.2-RC1 1.55.0 1.54.4 1.53.1 1.52.0 1.51.0 1.50.0 1.48.1 1.47.3 1.46.0 1.45.2 1.44.1 1.43.3 1.40.0 1.39.0 1.38.0 1.37.7 1.36.1 1.35.0 1.34.0 1.33.0 1.32.0 1.31.0 1.30.0 1.28.0 1.27.3 Reference documentation and code samples for the Cloud Firestore Client class FieldPath.

Represents a path to a Firestore Document field.

Example:

    use Google\Cloud\Firestore\FirestoreClient;

    $firestore = new FirestoreClient();
    $path = $firestore->fieldPath(['accounts', 'usd']);

## Namespace

Google \\ Cloud \\ Firestore

## Methods

### __construct

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `fieldNames` | `array` A list of field names. |

### child

Get a new FieldPath with the given path part appended to the current
path.

Example:

    $child = $path->child('element');

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `part` | `string` The child path part. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/FieldPath` |   |

### pathString

Get the current path as a string, with special characters escaped.

Example:

    $string = $path->pathString();

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### path

Get the path elements.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `array` |   |

### __toString

Cast the path to a string.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### static::documentId

Create a field path indicating the document ID.

Example:

    use Google\Cloud\Firestore\FieldPath;

    $path = FieldPath::documentId();

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/FieldPath` |   |

### static::fromString

Create a FieldPath from a string path.

Example:

    use Google\Cloud\Firestore\FieldPath;

    $path = FieldPath::fromString('path.to.field');

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `path` | `string` The field path string. |
| `splitPath` | `bool` If false, the input path will not be split on `.`. *Defaults to* \* `true`. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/php/docs/reference/cloud-firestore/latest/FieldPath` |   |

## Constants

### SPECIAL_CHARS

    Value: '/^[^*~\/[\]]+$/'

### UNESCAPED_FIELD_NAME

    Value: '/^[_a-zA-Z][_a-zA-Z0-9]*$/'