Creates an instance of a field, binding it to a bundle.
array $instance: A field instance definition array. The field_name, entity_type and bundle properties are required. Other properties, if omitted, will be given the following default values:
\Drupal\field\Plugin\Core\Entity\FieldInstance The field instance entity.
as of Drupal 8.0. Use entity_create('field_instance', $definition)->save().
function field_create_instance(array $instance) {
$instance = entity_create('field_instance', $instance);
$instance
->save();
return $instance;
}