Drush Commands : How to create feature in drupal

I’m going to explain how to create feature in drupal using drush commands. It is easy and recommended way to update codebase for configuration changes.

Here I’ve made example how to create , update or revert feature either from command line

We usually create new configuration, add fields through Drupal Admin UI,

For example:  If you have page content type and you’ll need to add another field for meta description. You can easily go into Admin UI and add new field.

After adding through UI , we can include it in our code base by using drush commands and deploy to live site which will then automatically update without going and change into UI.

Below are the drush commands and their execution to create , update or revert feature.

drush fc – shows components which are available to featurized

Command : drush fc

drush_fc
Now we can enter number for the component for which we want to create feature. For example if we add new field for the specific content type and we want to create feature for that particular content type, we’ll enter number 13 as content type is part of node component. After entering number 13, it shows the screen as shown below.  


Available sources

node:page               Provided by:pa_registrations_content_types

node:article

Pgae content type is already under pa_registrations_content_types feature and now will create new feature for article content type under same feature.

drush fe pa_registrations_content_types node:article -y –destination=”sites/all/modules/features”

It will export the changes for article content type to the “pa_generic _content_types” under feature directory. if we’ve added new field, it will be added it here as code implementation.

If you want to just update existing feature:
drush –y fu pa_registrations_content_types

Also, You can use feature revert to update your remote feature with latest changes.
drush –y fr pa_registrations_content_types

Command list to remember:
List: features-list (fl)
Available components to featurize: features-components(fc)
Create new feature : features-export (fe)
Update: features-update-all (fua) or features-update (fu)
Revert: features-revert-all (fra) or features-revert (fr)

 

Comments are closed.