<h1>Updating Features and Adding Components Using Drush</h1>
<pclass="posted">21st October 2014</p>
<p>If you use the <ahref="http://drupal.org/project/features">Features module</a> to manage your Drupal configuration, it can be time consuming to update features through the UI, especially if you are working on a remote server and need to keep downloading and uploading files.</p>
<p>If you re-create a feature through the UI, you'll be prompted to download a new archive of the feature in its entirety onto your local computer. You could either commit this into a local repository and then pull it remotely, or use a tool such as SCP to upload the archive onto the server and commit it from there. You can simplify this process by using <ahref="http://drush.org">Drush</a>.</p>
<p>To search for a component, use the <code>drush features-components</code> command. This will display a list of all components on the site. As we're only interested in components that haven't been exported yet, add the <code>--not-exported</code> option to filter the results.</p>
<p>To filter further, you can also use the <code>grep</code> command to filter the results. For example, <code>drush features-components --not-exported field_base | grep foo</code>, would only return non-exported field bases containing the word "foo".</p>
<p>The result is a source and a component, separated by a colon. For example, <code>field_base:field_foo</code>.</p>
<h2id="exporting-the-feature">Exporting the Feature</h2>
<p>Once you have a list of the components that you need to add, you can export the feature. This is done using the <code>drush features-export</code> command, along with the feature name and the component names.</p>
<p>In this example, the base for field_boo and it's instance on the user object is being added to the "myfeature" feature.</p>
<p>If you are updating an existing feature, you'll get a message informing you that the module already exists and asking if you want to continue. This is fine, and is automatically accepted by including <code>-y</code> within the command. If a feature with the specified name doesn't exist, it will be created.</p>
<p>If you're creating a new feature, you can define where the feature will be created using the <code>--destination</code> option.</p>
<p>Once complete, you will see a confirmation message.</p>
<blockquote>
<p>Created module: my feature in sites/default/modules/custom/features/myfeature</p>
</blockquote>
<h2id="the-result">The Result</h2>
<p>Once finished, the feature is updated in it's original location, so there's no download of the feature and then needing to re-upload it. You can add and commit your changes into Git or continue with your standard workflow straight away.</p>
<h2id="useful-links">Useful Links</h2>
<ul>
<li><ahref="http://www.drupal.org/project/features">The Features project page on Drupal.org</a></li>
<p>Oliver Davies is a Web Developer, System Administrator and Drupal specialist based in the UK. He is a Senior Developer at <ahref="https://microserve.io">Microserve</a> and also provides freelance consultancy services for Drupal websites, PHP applications and Linux servers.</p>
</div>
</main>
<divclass="col-md-3">
<divclass="panel badges text-center">
<aclass="badge--da-member"href="https://assoc.drupal.org/membership"title="I’m a Drupal Association member.">