# Taxonomy Repository

To work with the with `Taxonomy` Repository, use the following Facade:

```php
use Statamic\Facades\Taxonomy;
```

## Methods

| Methods | Description |
| ------- | ----------- |
| `all()` | Get all Taxonomies |
| `find($id)` | Get Taxonomy by `id` |
| `findByHandle($handle)` | Get Taxonomy by `handle` |
| `findByUri($mount)` | Get Taxonomy by `uri` |
| `findOrFail($id)` | Get Taxonomy by `id`. Throws a `TaxonomyNotFoundException` when the taxonomy cannot be found. |
| `handleExists($handle)` | Check to see if `Taxonomy` exists |
| `handles()` | Get all `Taxonomy` handles |
| `queryTerms()` | Query Builder for [Terms](/content-queries/term-repository.md) |
| `make()` | Makes a new `Taxonomy` instance |

:::tip
The `id` is the same as `handle` while using the default Stache driver.
:::

## Querying

While the `Taxonomy` Repository does not have a Query Builder, you can still query for Terms _inside_ Taxonomies with the `queryTerms` method. This approach can be useful for retrieving Terms with an existing Taxonomy object.

```php
$tags = Taxonomy::find('tags');

$tags->queryTerms()->get();
```

When a taxonomy can't be found, the `Taxonomy::find()` method will return `null`. If you'd prefer an exception be thrown, you may use the `findOrFail` method:

```php
Taxonomy::findOrFail('tags');
```

## Creating

Start by making an instance of a taxonomy with the `make` method. You can pass the handle into it.

```php
$taxonomy = Taxonomy::make('tags');
```

You may call additional methods on the taxonomy to customize it further.

```php
$taxonomy
    ->title('Tags')
    ->cascade($data) // an array
    ->revisionsEnabled(false)
    ->searchIndex('tags')
    ->defaultPublishState('published') // or 'draft'
    ->sites(['one', 'two']) // array of handles
```

Finally, save it.

```php
$taxonomy->save();
```
