SlideShare una empresa de Scribd logo
1 de 48
Descargar para leer sin conexión
Features based development workflow



        Antonio De Marco       Andrea Pescetti
          antonio@nuvole.org    andrea@nuvole.org
How can multiple developers work
 together on the same project?
Real life example

Peter
Location: Barcelona, Spain
Plans for Friday evening: working on stuff.




Antonio
Location: Brussels, Belgium
Plans for Friday evening: couple of Belgian beers, he’ll work later.
1. Sharing database dumps
Peter

$ svn up
U    dump.sql
Updated to revision 33.

..working...
..working...

$ drush sql-dump --result-file="dump.sql"
$ svn ci -m "Work done."
Later that night...
Antonio


..working...
..working...

$ drush sql-dump --result-file="dump.sql"
$ svn ci -m "Work done. Loves Leffe."


           Peter’s work is lost!
Major drawbacks


• Not ideal for a distributed team
• Makes it difficult to push settings to production
• Content and settings are mixed in one db dump
• Easy to lose control
2. Put everything in code
Major benefits


• Code can be versioned
• Conflicts can be solved
• Content and settings are separated
• Easy to push changes to production
Features: storing configuration in code
Features: storing configuration in code
feature_news.info
core = "6.x"
dependencies[] = "context"
dependencies[] = "features"
dependencies[] = "imagecache"
dependencies[] = "imagefield"
description = "Publish news."
features[content][] = "news-field_news_image"
features[context][] = "feature_news_list"
features[ctools][] = "context:context:3"
features[ctools][] = "strongarm:strongarm:1"
features[imagecache][] = "news-badge"
features[imagecache][] = "news-m"
features[imagecache][] = "news-s"
features[node][] = "news"
...
name = "Feature News"
package = "Features"
project = "feature_news"
version = "6.x-1.0-dev"
From DB to code and vice versa


  $ # Dump your changes into code.
  $ drush features-update feature_name

  $ # Restore your changes into the db.
  $ drush features-revert feature_name
Want to add a component to a feature?


1. add it to the .info file
2. $ drush features-update feature_name
Want to remove a component from a feature?


  1. remove it from the .info file
  2. $ drush features-update feature_name
Features are modules.
Modules can be updated.
Project bootstrap
project.make
project.profile
project.make



core = "6.x"

; Contrib
projects[features][version] = "1.0"
projects[features][subdir] = "contrib"

projects[views][version] = "2.11"
projects[views][subdir] = "contrib"

projects[cck][version] = "2.8"
projects[cck][subdir] = "contrib"

...
project.profile

/**
  * Implementation of hook_profile_details().
  */
function project_profile_details() {
   return array(
      'name' => 'Project',
      'description' => 'Project Description’,
   );
}

/**
 * Implementation of hook_profile_modules().
 */
function project_profile_modules() {

  $modules = array(
    'cck',
    'views',
    'features',
    'feature_controller',
    ...
The Controller Feature
 a.k.a. a feature to rule them all
Controller Feature Workflow
Developer A




                                                                                        Time
Developer B




                                                                                        Time




              Start: both Developers run installation, Controller Feature is enabled.
Controller Feature Workflow
Developer A




                                                            Time
Developer B




                                                            Time



              Developer A enables Rules module,
              Developer B does other work on the project.
hook_update_N()

/**
  * Enabling Rules module
  */
function feature_controller_update_6001() {
   $return = array();
   $modules = array('rules');
   drupal_install_modules($modules);
   $return[] = array('success' => TRUE, 'query' => 'Enabling Rules module');
   return $return;
}
Controller Feature Workflow

              6001
Developer A




                                                  Time
Developer B




                                                  Time




               Developer A commits his changes.
Controller Feature Workflow

              6001
Developer A




                                                          Time
Developer B




                                                          Time



                     Developer B updates his local copy
                     and removes a role.
hook_update_N()
/**
  * Removing contributor role
  */
function feature_controller_update_6002() {
   $return = array();
   $role_name = 'contributor';
   $result = db_query("SELECT rid FROM {role} WHERE name='%s'", $role_name);
   while ($role = db_fetch_object($result)) {
     $rid = $role->rid;
     $return[] = update_sql("DELETE FROM {role} WHERE rid = '$rid'");
     $return[] = update_sql("DELETE FROM {users_roles} WHERE rid = '$rid'");
   }
   return $return;
}
Controller Feature Workflow

              6001
Developer A




                                                         Time
Developer B




                     6002

                                                         Time




                      Developer B commits his changes.
Controller Feature Workflow

              6001
Developer A




                                                                            Time
Developer B




                     6002

                                                                            Time




                            Developer B adds an OpenID account for admin.
hook_update_N()

/**
  * Adding Nuvole OpenID to admin account
  */
function feature_controller_update_6003() {
   $return = array();
   $uid = 1;
   $claimed_id = 'http://nuvole.myopenid.com/';
   $return[] = update_sql("DELETE FROM {authmap} WHERE authname = '$claimed_id'");
   $return[] = update_sql("INSERT INTO {authmap}(uid, authname, module)
                           VALUES($uid, '$claimed_id', 'openid')");
   return $return;
}
Controller Feature Workflow

              6001
Developer A




                                                                Time
Developer B




                     6002   6003

                                                                Time




                             Developer B commits his changes.
Controller Feature Workflow

              6001
Developer A




                                                                      Time
Developer B




                     6002   6003

                                                                      Time
                                   Developer C




                                                                      Time

                                                 Developer C joins.
Updates are not enough.
Controller Feature Workflow

              6001
Developer A




                                                 Time
Developer B




                     6002   6003

                                                 Time
                                   Developer C




                                                 Time


feature_controller_install()
hook_install()

/**
 * Implementation of hook_install()
 */
function feature_controller_install() {
  $return = array();

    $modules = array('rules');
    drupal_install_modules($modules);
    $return[] = array('success' => TRUE, 'query' => 'Enable Rules module.');

    $uid = 1;
    $claimed_id = 'http://nuvole.myopenid.com/';
    $return[] = update_sql("INSERT INTO {authmap}(uid, authname, module)
                            VALUES($uid, '$claimed_id', 'openid')");
    return $return;
}
Controller Feature Workflow

              6001
Developer A




                                                                                     Time
Developer B




                     6002   6003

                                                                                     Time
                                   Developer C




                                                                                     Time

                                                 Developer C installs the project.
Controller Feature Workflow

              6001
Developer A




                                                                                     Time
Developer B




                     6002   6003

                                                                                     Time
                                   Developer C




                                                                                     Time

                                          Developer C creates and enables a new feature.
hook_update_N()

/**
  * Enabling News feature
  */
function feature_controller_update_6004() {
   $return = array();
   $modules = array('feature_news');
   features_install_modules($modules);
   $return[] = array('success' => TRUE, 'query' => 'Enabling News');
   return $return;
}
/**
 * Implementation of hook_install()
 */
function feature_controller_install() {
  $return = array();

    $modules = array('rules');
    drupal_install_modules($modules);
    $return[] = array('success' => TRUE, 'query' => 'Enable Rules module.');

    $uid = 1;
    $claimed_id = 'http://nuvole.myopenid.com/';
    $return[] = update_sql("INSERT INTO {authmap}(uid, authname, module)
                            VALUES($uid, '$claimed_id', 'openid')");

    $modules = array('feature_news');
    features_install_modules($modules);
    $return[] = array('success' => TRUE, 'query' => 'Enabling News');

    return $return;
}
Controller Feature Workflow

              6001
Developer A




                                                                                 Time
Developer B




                     6002   6003

                                                                                 Time
                                   Developer C




                                                 6004

                                                                                 Time

                                                  Developer C commits his changes.
Code conventions for a better world.
Feature namespace
# Feature News (feature_news)

Views                feature_news_blocks
                     feature_news_list
                     feature_news_node
                     feature_news_taxonomy

Contexts             feature_news_front
                     feature_news_list

Openlayers Presets   feature_news_small_map
                     feature_news_big_map
Content type namespace
# News (news)

CCK Fields           field_news_pictures
                     field_news_links

Imagecache Presets   news-s
                     news-m
                     news-l
                     news-portrait
References:

http://drupal.org/project/features

http://drupal.org/project/kit

http://drupal.org/project/buildkit
Thank You.

 http://nuvole.org
   @nuvoleweb

Más contenido relacionado

Destacado

Code driven development in drupal
Code driven development in drupalCode driven development in drupal
Code driven development in drupalAndriy Yun
 
Automating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondAutomating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondNuvole
 
Electrolux na Designblok
Electrolux na DesignblokElectrolux na Designblok
Electrolux na DesignblokPleon Impact
 
Aunties power point ECMM
Aunties power point ECMMAunties power point ECMM
Aunties power point ECMMcherise dash
 
Vintage Power Boat Racing Program Havasu 1967
Vintage Power Boat Racing Program Havasu 1967Vintage Power Boat Racing Program Havasu 1967
Vintage Power Boat Racing Program Havasu 1967idn12
 
Guestbook Hotel Tirsus Aggiornato Maggio 2012
Guestbook Hotel Tirsus Aggiornato Maggio  2012Guestbook Hotel Tirsus Aggiornato Maggio  2012
Guestbook Hotel Tirsus Aggiornato Maggio 2012hoteltirsus
 
Welcome to my power point
Welcome to my power pointWelcome to my power point
Welcome to my power pointsiata123
 
Apresentaçao bbom+ grupo valemais
Apresentaçao bbom+ grupo valemaisApresentaçao bbom+ grupo valemais
Apresentaçao bbom+ grupo valemaisRENATO SILVA
 
Hkd2 cph berit_puggard_tns_demystifying_consumers
Hkd2 cph berit_puggard_tns_demystifying_consumersHkd2 cph berit_puggard_tns_demystifying_consumers
Hkd2 cph berit_puggard_tns_demystifying_consumersH&K Demystifying Digital
 
Silver ball pr slideshow
Silver ball pr slideshowSilver ball pr slideshow
Silver ball pr slideshowalexcrisp91
 

Destacado (17)

Code driven development in drupal
Code driven development in drupalCode driven development in drupal
Code driven development in drupal
 
Automating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondAutomating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyond
 
Electrolux na Designblok
Electrolux na DesignblokElectrolux na Designblok
Electrolux na Designblok
 
Protocolos
ProtocolosProtocolos
Protocolos
 
Dec.3
Dec.3Dec.3
Dec.3
 
Anil Kumar CV
Anil Kumar CVAnil Kumar CV
Anil Kumar CV
 
Aunties power point ECMM
Aunties power point ECMMAunties power point ECMM
Aunties power point ECMM
 
Vintage Power Boat Racing Program Havasu 1967
Vintage Power Boat Racing Program Havasu 1967Vintage Power Boat Racing Program Havasu 1967
Vintage Power Boat Racing Program Havasu 1967
 
Final report
Final reportFinal report
Final report
 
Guestbook Hotel Tirsus Aggiornato Maggio 2012
Guestbook Hotel Tirsus Aggiornato Maggio  2012Guestbook Hotel Tirsus Aggiornato Maggio  2012
Guestbook Hotel Tirsus Aggiornato Maggio 2012
 
Welcome to my power point
Welcome to my power pointWelcome to my power point
Welcome to my power point
 
Pune Wine fest
Pune Wine festPune Wine fest
Pune Wine fest
 
Apresentaçao bbom+ grupo valemais
Apresentaçao bbom+ grupo valemaisApresentaçao bbom+ grupo valemais
Apresentaçao bbom+ grupo valemais
 
Hkd2 cph berit_puggard_tns_demystifying_consumers
Hkd2 cph berit_puggard_tns_demystifying_consumersHkd2 cph berit_puggard_tns_demystifying_consumers
Hkd2 cph berit_puggard_tns_demystifying_consumers
 
Silver ball pr slideshow
Silver ball pr slideshowSilver ball pr slideshow
Silver ball pr slideshow
 
#5
#5#5
#5
 
Creative commons
Creative commonsCreative commons
Creative commons
 

Similar a Features based development workflow

Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JSBipin
 
Introducing Pebble SDK 2.0
Introducing Pebble SDK 2.0Introducing Pebble SDK 2.0
Introducing Pebble SDK 2.0Cherie Williams
 
Baking docker using chef
Baking docker using chefBaking docker using chef
Baking docker using chefMukta Aphale
 
Baking Docker Using Chef - ChefConf 2015
Baking Docker Using Chef - ChefConf 2015Baking Docker Using Chef - ChefConf 2015
Baking Docker Using Chef - ChefConf 2015Chef
 
First Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven DevelopmentFirst Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven DevelopmentNuvole
 
Provisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
Provisioning & Migration with p2: Case study - The Good, the Bad and the UglyProvisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
Provisioning & Migration with p2: Case study - The Good, the Bad and the Uglychristianbourgeois
 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersOswald Campesato
 
1 Database Security Lab 2 – Virtual Private Database.docx
1 Database Security Lab 2 – Virtual Private Database.docx1 Database Security Lab 2 – Virtual Private Database.docx
1 Database Security Lab 2 – Virtual Private Database.docxjeremylockett77
 
SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...
SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...
SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...Sencha
 
Spring Boot Loves K8s
Spring Boot Loves K8sSpring Boot Loves K8s
Spring Boot Loves K8sVMware Tanzu
 
Top 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers MakeTop 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers MakeMark Meyer
 
Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to productionFDConf
 
Openshift operator insight
Openshift operator insightOpenshift operator insight
Openshift operator insightRyan ZhangCheng
 
Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6William Marques
 
Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to productionJenya Terpil
 
Spring Performance Gains
Spring Performance GainsSpring Performance Gains
Spring Performance GainsVMware Tanzu
 
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...Docker, Inc.
 

Similar a Features based development workflow (20)

Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JS
 
Introducing Pebble SDK 2.0
Introducing Pebble SDK 2.0Introducing Pebble SDK 2.0
Introducing Pebble SDK 2.0
 
Announcing Pebble SDK 2.0
Announcing Pebble SDK 2.0Announcing Pebble SDK 2.0
Announcing Pebble SDK 2.0
 
Baking docker using chef
Baking docker using chefBaking docker using chef
Baking docker using chef
 
Baking Docker Using Chef - ChefConf 2015
Baking Docker Using Chef - ChefConf 2015Baking Docker Using Chef - ChefConf 2015
Baking Docker Using Chef - ChefConf 2015
 
First Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven DevelopmentFirst Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven Development
 
Provisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
Provisioning & Migration with p2: Case study - The Good, the Bad and the UglyProvisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
Provisioning & Migration with p2: Case study - The Good, the Bad and the Ugly
 
Angular1x and Angular 2 for Beginners
Angular1x and Angular 2 for BeginnersAngular1x and Angular 2 for Beginners
Angular1x and Angular 2 for Beginners
 
1 Database Security Lab 2 – Virtual Private Database.docx
1 Database Security Lab 2 – Virtual Private Database.docx1 Database Security Lab 2 – Virtual Private Database.docx
1 Database Security Lab 2 – Virtual Private Database.docx
 
SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...
SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...
SenchaCon 2016: Enterprise Applications, Role Based Access Controls (RBAC) an...
 
Spring Boot Loves K8s
Spring Boot Loves K8sSpring Boot Loves K8s
Spring Boot Loves K8s
 
Top 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers MakeTop 10 Mistakes AngularJS Developers Make
Top 10 Mistakes AngularJS Developers Make
 
Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to production
 
angular fundamentals.pdf
angular fundamentals.pdfangular fundamentals.pdf
angular fundamentals.pdf
 
Openshift operator insight
Openshift operator insightOpenshift operator insight
Openshift operator insight
 
Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6Angular 2 Migration - JHipster Meetup 6
Angular 2 Migration - JHipster Meetup 6
 
Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to production
 
Spring Performance Gains
Spring Performance GainsSpring Performance Gains
Spring Performance Gains
 
Active x
Active xActive x
Active x
 
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
 

Más de Nuvole

The OpenEuropa Initiative
The OpenEuropa InitiativeThe OpenEuropa Initiative
The OpenEuropa InitiativeNuvole
 
CMI 2.0 session at Drupal DevDays in Cluj-Napoca
CMI 2.0 session at Drupal DevDays in Cluj-NapocaCMI 2.0 session at Drupal DevDays in Cluj-Napoca
CMI 2.0 session at Drupal DevDays in Cluj-NapocaNuvole
 
Advanced Configuration Management with Config Split et al.
Advanced Configuration Management with Config Split et al.Advanced Configuration Management with Config Split et al.
Advanced Configuration Management with Config Split et al.Nuvole
 
Introducing the UI Patterns module: use atomic UI components everywhere in Dr...
Introducing the UI Patterns module: use atomic UI components everywhere in Dr...Introducing the UI Patterns module: use atomic UI components everywhere in Dr...
Introducing the UI Patterns module: use atomic UI components everywhere in Dr...Nuvole
 
Drupal 8 Configuration Management with Features
Drupal 8 Configuration Management with FeaturesDrupal 8 Configuration Management with Features
Drupal 8 Configuration Management with FeaturesNuvole
 
Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)
Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)
Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)Nuvole
 
Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)
Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)
Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)Nuvole
 
Building and Maintaining a Distribution in Drupal 7 with Features
Building and Maintaining a  Distribution in Drupal 7 with FeaturesBuilding and Maintaining a  Distribution in Drupal 7 with Features
Building and Maintaining a Distribution in Drupal 7 with FeaturesNuvole
 
Remote Collaboration and Institutional Intranets with Drupal and Open Atrium
Remote Collaboration and Institutional Intranets with Drupal and Open AtriumRemote Collaboration and Institutional Intranets with Drupal and Open Atrium
Remote Collaboration and Institutional Intranets with Drupal and Open AtriumNuvole
 
Public Works Monitoring
Public Works MonitoringPublic Works Monitoring
Public Works MonitoringNuvole
 
Extending and Customizing Open Atrium
Extending and Customizing Open AtriumExtending and Customizing Open Atrium
Extending and Customizing Open AtriumNuvole
 

Más de Nuvole (11)

The OpenEuropa Initiative
The OpenEuropa InitiativeThe OpenEuropa Initiative
The OpenEuropa Initiative
 
CMI 2.0 session at Drupal DevDays in Cluj-Napoca
CMI 2.0 session at Drupal DevDays in Cluj-NapocaCMI 2.0 session at Drupal DevDays in Cluj-Napoca
CMI 2.0 session at Drupal DevDays in Cluj-Napoca
 
Advanced Configuration Management with Config Split et al.
Advanced Configuration Management with Config Split et al.Advanced Configuration Management with Config Split et al.
Advanced Configuration Management with Config Split et al.
 
Introducing the UI Patterns module: use atomic UI components everywhere in Dr...
Introducing the UI Patterns module: use atomic UI components everywhere in Dr...Introducing the UI Patterns module: use atomic UI components everywhere in Dr...
Introducing the UI Patterns module: use atomic UI components everywhere in Dr...
 
Drupal 8 Configuration Management with Features
Drupal 8 Configuration Management with FeaturesDrupal 8 Configuration Management with Features
Drupal 8 Configuration Management with Features
 
Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)
Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)
Configuration Management in Drupal 8: A preview (DrupalCamp Alpe Adria 2014)
 
Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)
Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)
Configuration Management in Drupal 8: A preview (DrupalDays Milano 2014)
 
Building and Maintaining a Distribution in Drupal 7 with Features
Building and Maintaining a  Distribution in Drupal 7 with FeaturesBuilding and Maintaining a  Distribution in Drupal 7 with Features
Building and Maintaining a Distribution in Drupal 7 with Features
 
Remote Collaboration and Institutional Intranets with Drupal and Open Atrium
Remote Collaboration and Institutional Intranets with Drupal and Open AtriumRemote Collaboration and Institutional Intranets with Drupal and Open Atrium
Remote Collaboration and Institutional Intranets with Drupal and Open Atrium
 
Public Works Monitoring
Public Works MonitoringPublic Works Monitoring
Public Works Monitoring
 
Extending and Customizing Open Atrium
Extending and Customizing Open AtriumExtending and Customizing Open Atrium
Extending and Customizing Open Atrium
 

Features based development workflow

  • 1. Features based development workflow Antonio De Marco Andrea Pescetti antonio@nuvole.org andrea@nuvole.org
  • 2. How can multiple developers work together on the same project?
  • 3. Real life example Peter Location: Barcelona, Spain Plans for Friday evening: working on stuff. Antonio Location: Brussels, Belgium Plans for Friday evening: couple of Belgian beers, he’ll work later.
  • 5. Peter $ svn up U dump.sql Updated to revision 33. ..working... ..working... $ drush sql-dump --result-file="dump.sql" $ svn ci -m "Work done."
  • 7. Antonio ..working... ..working... $ drush sql-dump --result-file="dump.sql" $ svn ci -m "Work done. Loves Leffe." Peter’s work is lost!
  • 8. Major drawbacks • Not ideal for a distributed team • Makes it difficult to push settings to production • Content and settings are mixed in one db dump • Easy to lose control
  • 9.
  • 10. 2. Put everything in code
  • 11. Major benefits • Code can be versioned • Conflicts can be solved • Content and settings are separated • Easy to push changes to production
  • 14.
  • 15. feature_news.info core = "6.x" dependencies[] = "context" dependencies[] = "features" dependencies[] = "imagecache" dependencies[] = "imagefield" description = "Publish news." features[content][] = "news-field_news_image" features[context][] = "feature_news_list" features[ctools][] = "context:context:3" features[ctools][] = "strongarm:strongarm:1" features[imagecache][] = "news-badge" features[imagecache][] = "news-m" features[imagecache][] = "news-s" features[node][] = "news" ... name = "Feature News" package = "Features" project = "feature_news" version = "6.x-1.0-dev"
  • 16. From DB to code and vice versa $ # Dump your changes into code. $ drush features-update feature_name $ # Restore your changes into the db. $ drush features-revert feature_name
  • 17. Want to add a component to a feature? 1. add it to the .info file 2. $ drush features-update feature_name
  • 18. Want to remove a component from a feature? 1. remove it from the .info file 2. $ drush features-update feature_name
  • 19. Features are modules. Modules can be updated.
  • 22. project.make core = "6.x" ; Contrib projects[features][version] = "1.0" projects[features][subdir] = "contrib" projects[views][version] = "2.11" projects[views][subdir] = "contrib" projects[cck][version] = "2.8" projects[cck][subdir] = "contrib" ...
  • 23. project.profile /** * Implementation of hook_profile_details(). */ function project_profile_details() { return array( 'name' => 'Project', 'description' => 'Project Description’, ); } /** * Implementation of hook_profile_modules(). */ function project_profile_modules() { $modules = array( 'cck', 'views', 'features', 'feature_controller', ...
  • 24. The Controller Feature a.k.a. a feature to rule them all
  • 25. Controller Feature Workflow Developer A Time Developer B Time Start: both Developers run installation, Controller Feature is enabled.
  • 26. Controller Feature Workflow Developer A Time Developer B Time Developer A enables Rules module, Developer B does other work on the project.
  • 27. hook_update_N() /** * Enabling Rules module */ function feature_controller_update_6001() { $return = array(); $modules = array('rules'); drupal_install_modules($modules); $return[] = array('success' => TRUE, 'query' => 'Enabling Rules module'); return $return; }
  • 28. Controller Feature Workflow 6001 Developer A Time Developer B Time Developer A commits his changes.
  • 29. Controller Feature Workflow 6001 Developer A Time Developer B Time Developer B updates his local copy and removes a role.
  • 30. hook_update_N() /** * Removing contributor role */ function feature_controller_update_6002() { $return = array(); $role_name = 'contributor'; $result = db_query("SELECT rid FROM {role} WHERE name='%s'", $role_name); while ($role = db_fetch_object($result)) { $rid = $role->rid; $return[] = update_sql("DELETE FROM {role} WHERE rid = '$rid'"); $return[] = update_sql("DELETE FROM {users_roles} WHERE rid = '$rid'"); } return $return; }
  • 31. Controller Feature Workflow 6001 Developer A Time Developer B 6002 Time Developer B commits his changes.
  • 32. Controller Feature Workflow 6001 Developer A Time Developer B 6002 Time Developer B adds an OpenID account for admin.
  • 33. hook_update_N() /** * Adding Nuvole OpenID to admin account */ function feature_controller_update_6003() { $return = array(); $uid = 1; $claimed_id = 'http://nuvole.myopenid.com/'; $return[] = update_sql("DELETE FROM {authmap} WHERE authname = '$claimed_id'"); $return[] = update_sql("INSERT INTO {authmap}(uid, authname, module) VALUES($uid, '$claimed_id', 'openid')"); return $return; }
  • 34. Controller Feature Workflow 6001 Developer A Time Developer B 6002 6003 Time Developer B commits his changes.
  • 35. Controller Feature Workflow 6001 Developer A Time Developer B 6002 6003 Time Developer C Time Developer C joins.
  • 36. Updates are not enough.
  • 37. Controller Feature Workflow 6001 Developer A Time Developer B 6002 6003 Time Developer C Time feature_controller_install()
  • 38. hook_install() /** * Implementation of hook_install() */ function feature_controller_install() { $return = array(); $modules = array('rules'); drupal_install_modules($modules); $return[] = array('success' => TRUE, 'query' => 'Enable Rules module.'); $uid = 1; $claimed_id = 'http://nuvole.myopenid.com/'; $return[] = update_sql("INSERT INTO {authmap}(uid, authname, module) VALUES($uid, '$claimed_id', 'openid')"); return $return; }
  • 39. Controller Feature Workflow 6001 Developer A Time Developer B 6002 6003 Time Developer C Time Developer C installs the project.
  • 40. Controller Feature Workflow 6001 Developer A Time Developer B 6002 6003 Time Developer C Time Developer C creates and enables a new feature.
  • 41. hook_update_N() /** * Enabling News feature */ function feature_controller_update_6004() { $return = array(); $modules = array('feature_news'); features_install_modules($modules); $return[] = array('success' => TRUE, 'query' => 'Enabling News'); return $return; }
  • 42. /** * Implementation of hook_install() */ function feature_controller_install() { $return = array(); $modules = array('rules'); drupal_install_modules($modules); $return[] = array('success' => TRUE, 'query' => 'Enable Rules module.'); $uid = 1; $claimed_id = 'http://nuvole.myopenid.com/'; $return[] = update_sql("INSERT INTO {authmap}(uid, authname, module) VALUES($uid, '$claimed_id', 'openid')"); $modules = array('feature_news'); features_install_modules($modules); $return[] = array('success' => TRUE, 'query' => 'Enabling News'); return $return; }
  • 43. Controller Feature Workflow 6001 Developer A Time Developer B 6002 6003 Time Developer C 6004 Time Developer C commits his changes.
  • 44. Code conventions for a better world.
  • 45. Feature namespace # Feature News (feature_news) Views feature_news_blocks feature_news_list feature_news_node feature_news_taxonomy Contexts feature_news_front feature_news_list Openlayers Presets feature_news_small_map feature_news_big_map
  • 46. Content type namespace # News (news) CCK Fields field_news_pictures field_news_links Imagecache Presets news-s news-m news-l news-portrait