> For the complete documentation index, see [llms.txt](https://docs.hivepress.io/developer-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hivepress.io/developer-docs/framework/configurations.md).

# Configurations

In HivePress, configurations are defined as PHP arrays of parameters. For example, the `post_types` configuration contains parameters for registering the custom [post types](https://developer.wordpress.org/plugins/post-types/registering-custom-post-types/). Configuration files are stored in the `includes/configs` subdirectory of HivePress and its extensions. You can retrieve or extend configurations via the HivePress API.

### Creating configurations <a href="#bkmrk-creating-configurati" id="bkmrk-creating-configurati"></a>

If you are developing a custom HivePress [extension](/developer-docs/tutorials/create-a-custom-hivepress-extension.md), you may need to create a new configuration. To do this, create a new `{config-name}.php` file (use lowercase letters, numbers, and hyphens only) in the `includes/configs` extension subdirectory and HivePress will load it automatically. Pick a name unique enough to avoid conflicts with other HivePress configurations. For this example, we will name it `foo-bar.php`.

After the file is created, add the `return` statement with an array of parameters:

```php
return [
	'one'   => 'One',
	'two'   => 'Two',
	'three' => 'Three',
];
```

### Retrieving configurations <a href="#bkmrk-retrieving-configura" id="bkmrk-retrieving-configura"></a>

To retrieve a configuration, call the core `get_config` method with the configuration name:

```php
$config = hivepress()->get_config( 'foo_bar' );
```

The configuration name is the same as its filename but with underscores instead of hyphens. In the same way, you can retrieve any of the available configurations. For example, you can get an array of post types registered by HivePress:

```php
$post_types = hivepress()->get_config( 'post_types' );
```

### Extending configurations <a href="#bkmrk-extending-configurat" id="bkmrk-extending-configurat"></a>

To extend the configuration array, use the `hivepress/v1/{config_name}` filter hook. The code below adds a new array item to the `foo_bar` configuration:

```php
add_filter(
	'hivepress/v1/foo_bar',
	function( $config ) {
		$config['four'] = 'Four';

		return $config;
	}
);
```

Also, if you create a configuration file with the name of an existing one, HivePress will merge both automatically. For example, if you want to register a custom post type for your extension, simply create the `post-types.php` file in the `includes/configs` subdirectory, add an array of post type parameters, and HivePress will register it automatically.
