create_field
No security coverage
Takes the drush fc field:create and makes a class out of it called CreateFieldManager to simplify creating fields in a custom module. It exposes one public function fieldCreate(array $options) that takes the same array of options as the fieldCreate function in Drush\Commands\field\FieldCreateCommands.
Installation
Create a new Drupal installation to test. Add a biography content type. Download and install the module. There is a tester module that comes with it. It creates and deletes a field automatically when you hit the controller route so you know how to use it so make sure you have built a test environment.
If there is a need for this in Core I would love to see it end up there.
Options
entity-typeString
REQUIRED
The machine name of the entity type. bundle
String
REQUIRED
The machine name of the bundle. field-name
String
REQUIRED
A unique machine-readable name containing letters, numbers, and underscores. field-label
String
REQUIRED
The field label. field-description
String
OPTIONAL
Instructions to present to the user below this field on the editing form. field-type
String
REQUIRED
The field type. field-widget
String
OPTIONAL
The field widget. Will select the default widget automagically. is-required
Boolean
REQUIRED
Whether the field is required. is-translatable
Boolean
REQUIRED
Whether the field is translatable. cardinality
Integer
REQUIRED
The allowed number of values. target-type
String
OPTIONAL
The target entity type. Only necessary for entity reference fields. target-bundle
String
OPTIONAL
The target bundle(s). Only necessary for entity reference fields. show-machine-names
Boolean
REQUIRED
Show machine names instead of labels in option lists. existing-field-name
String
OPTIONAL
The name of an existing field you want to re-use. Only used in non-interactive context. existing
Boolean
REQUIRED
Re-use an existing field.