towards the perfect drupal dev machine

22
How to setup the perfect development environment Roel De Meester

Upload: krimson

Post on 08-May-2015

2.493 views

Category:

Technology


2 download

DESCRIPTION

Slides from presentation in Drupal Room at Fosdem 2010 in Brussels. Presentation from Roel De Meester

TRANSCRIPT

Page 1: Towards the perfect Drupal Dev Machine

How to setup the perfect development environment

Roel De Meester

Page 2: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

How to setup the perfect development environment

Towards some drupal development environment

Page 3: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

Poll

● Want to see installation process ?

● Want to discuss the result ?

Page 4: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

LAMP Server

● Start from a freshly installed UBUNTU

● Needs● xAMP Stack● Ready for drupal● Ready for drush● Ready to code

Page 5: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

LAMP Server – the script 1/2

#PREPARE ubuntu dev machinesudo apt-get update#sudo apt-get upgradesudo tasksel install lamp-server sudo apt-get install phpmyadminsudo apt-get install php5-clisudo apt-get install curl php5-curlsudo apt-get install php5-xdebugsudo apt-get install subversionsudo apt-get install php5-dev php-pear

Page 6: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

LAMP Server – the script 2/2

sudo sed -i 's/memory_limit = .*/memory_limit = 128M/' /etc/php5/apache2/php.ini

sudo sed -i 's/upload_max_filesize = .*/upload_max_filesize = 128M/' /etc/php5/apache2/php.inisudo sed -i 's/post_max_size = .*/post_max_size = 256M/' /etc/php5/apache2/php.ini

#better uploadprogress barsudo pecl install uploadprogresssudo sed -i '/; extension_dir directive above/ a\extension=uploadprogress.so' /etc/php5/apache2/php.ini

#cleanurl sudo sed -i 's/AllowOverride (None)/AllowOverride All/' /etc/apache2/sites-available/defaultsudo a2enmod rewrite && sudo /etc/init.d/apache2 restart

Page 7: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

LAMP Server – Automated

mkdir ~/bincd ~/binrm setup_ubuntu.shwget http://krimson.be/sites/default/files/setup_ubuntu.sh && chmod +x *.sh && ./setup_ubuntu.sh

Page 8: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

Drush

● Control Drupal from Terminal

● Needs● php-cli● curl● drush

Page 9: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

Drush – the script 1/3#default directory structureDEFAULT_WORKSPACE=$HOME/workspaceif [ ! -d "$DEFAULT_WORKSPACE" ];then echo "create workspace folder" mkdir $DEFAULT_WORKSPACEficd $DEFAULT_WORKSPACE

#install drush#NOTE : WHEN changing the drush folder, also update the $PROFILE_PATHDRUSH_ROOT=$DEFAULT_WORKSPACE/drushPROFILE_PATH='\n # set PATH so it includes drush if it exists \nif [ -d "$HOME/workspace/drush" ] ; then \n\t PATH="$HOME/workspace/drush:$PATH" \nfi \n'

Page 10: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

DRUSH – the script 2/3

DRUSH_VERSION=2.1DRUSH_TGZ=drush-All-Versions-$DRUSH_VERSION.tar.gz if [ ! -d "$DRUSH_ROOT" ];then echo "grabbing drush" wget http://ftp.drupal.org/files/projects/$DRUSH_TGZ if [ -a "$DRUSH_TGZ" ];then tar -zxvf $DRUSH_TGZ rm $DRUSH_TGZ else echo "ERROR : unable to download $DRUSH_TGZ" fifi

#add drush to path

Page 11: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

DRUSH – the script 3/3if grep -q drush ~/.profile then echo 'DRUSH already in path' else echo -e $PROFILE_PATH >> ~/.profile source ~/.profile echo '----------------------------------------------------------------------| Please update your path by reloading your .profile. || Just run the command at the bottom from your terminal. || Note : this will only work in current shell. if you want a decent || DEV environment, you should logout/login. || || the command to run : || || . ~/.profile |----------------------------------------------------------------------'fi

Page 12: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

DRUSH – Automated

mkdir ~/bincd ~/binrm setup_drush.shwget http://krimson.be/sites/default/files/setup_drush.sh && chmod +x *.sh && ./setup_drush.sh

Page 13: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

An IDE

● Eclipse – VI – Emacs – Bluefish- geany - ..

Page 14: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

Install Eclipse – the steps

● Install JRE – Java Runtime

● Manual or APT-Get ?

● Startup script

● Eclipse has● Code completion● Debug support● Version Control support

● Eclipse is heavy to launch

Page 15: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

Install Eclipse – the script 1/2

#!/usr/bin/php -q<?php$ECLIPSE_DOWNLOAD_URL="http://d2u376ub0heus3.cloudfront.net/technology/epp/downloads/release/galileo/SR1/eclipse-php-galileo-SR1-linux-gtk.tar.gz";$ECLIPSE_TAR_NAME=basename($ECLIPSE_DOWNLOAD_URL);$ECLIPSE_NEW_FOLDER_NAME="eclipse-pdt-galileo";$ECLIPSE_BIN_FILE="eclipse";

echo "#Install JAVA Runtime\n";passthru("sudo apt-get install sun-java6-jre sun-java6-plugin sun-java6-fonts");

echo "#Get Eclipse ("+$ECLIPSE_NEW_FOLDER_NAME+") \n";passthru("mkdir -p ~/bin/packages");

# ...to be continued

Page 16: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

Install Eclipse – the script 2/2

exec("wget " . $ECLIPSE_DOWNLOAD_URL); system("mv " . $ECLIPSE_TAR_NAME . " ~/bin/packages/"); system("cd ~/bin/packages/ && tar -zxvf $ECLIPSE_TAR_NAME && rm $ECLIPSE_TAR_NAME && mv eclipse $ECLIPSE_NEW_FOLDER_NAME");

if (!file_exists($ECLIPSE_BIN_FILE)){$fh = fopen($ECLIPSE_BIN_FILE, 'w') or die("can't open file

$ECLIPSE_BIN_FILE\n");$stringData = "#/bin/bash\n";fwrite($fh, $stringData);$stringData = "`~/bin/packages/$ECLIPSE_NEW_FOLDER_NAME/eclipse

-data ~/eclipse-workspace -vmargs -Xms128M -Xmx512M -XX:PermSize=128M -XX:MaxPermSize=512M &> /dev/null` & \n";

fwrite($fh, $stringData);fclose($fh);

system("chmod u+x eclipse && mv eclipse ~/bin/eclipse") ; }?>

Page 17: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

Eclipse – Automated

cd ~/binwget http://krimson.be/sites/default/files/setup_eclipse.php.txt && mv setup_eclipse.php.txt setup_eclipse.php && chmod +x *.php && ./setup_eclipse.php

Page 18: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

Eclipse – Extra's

● CSS Editing : Aptana

http://update.aptana.com/install/studio

● SVN Version Control : subclipsehttp://subclipse.tigris.org/update_1.6.x

● Unfuddle : Mylyn Connectorhttp://unfuddle.com/downloads/plugins/mylyn/e3.5/update-site/

● Drupal settings + Drush launcher

http://xtnd.us/downloads/eclipse

Page 19: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

Eclipse – Configuration● Mylyn

● Allows you to list tasks from bug tracking sytem● Allows you to start working on task and keep

track of all 'touched' files and provides context around a bug.

● Allows you to close tasks from within eclipse● Unfuddle HAS a connector!

● Xdebug - krimson.be/articles/debugging-drupal-6-using-xdebug

● Allows you to go through your running code step by step

Page 20: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

Your company standards

● How we do it @ Krimson

● svn_new_project.sh spellen● Checkout, virtualhost, database, multidomain,

load db dump, done ● Internal commands + conventions keeps us up

to speed

Page 21: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

Drupal – Extra's

● devel module● print functions - dsm● theme developer

● switch users● http://drupal.org/project/masquerade

● Prevent test mails to prime ministers● http://drupal.org/project/reroute_email

● http://drupal.org/project/schema

● http://drupal.org/project/coder

Page 22: Towards the perfect Drupal Dev Machine

07/02/10 Fosdem 2010 : Drupal Dev Machine

Firefox – Extra's

● Firebug

● Webdeveloper toolbar