• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Drush 原理与应用
 

Drush 原理与应用

on

  • 1,401 views

关于Drupal drush项目的入门介绍,以及一些引申话题。

关于Drupal drush项目的入门介绍,以及一些引申话题。

Statistics

Views

Total Views
1,401
Views on SlideShare
1,401
Embed Views
0

Actions

Likes
2
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Drush 原理与应用 Drush 原理与应用 Presentation Transcript

    • 于志成@Zinch
      vipzhicheng@gmail.com
      http://www.drupal001.com
      Drush 原理与应用
    • Drush概述
      Drush原理
      Drush安装
      Drush应用
      Drush未来
      演示
      大纲
    • 什么是Drush?
      Drush能做什么?
      谁需要用Drush?
      Drush相关资源
      Drush概述
    • 什么是Drush?
    • Drush = Drupal + shell
    • Drupal <-> Drush <-> Linux
    • $drush cc
      Enter a number to choose which cache to clear.
      [0] : Cancel
      [1] : all
      [2] : theme registry
      [3] : menu
      [4] : css+js
      [5] : block
      [6] : module list
      [7] : theme list
      [8] : registry
    • 什么是Drush
      开始于
      2006 by Arto
      第一个版本基于drupal4.7
      思路来自于当年的DrupalCon
      目前
      稳定版:drush 4.5,最低版本php5.2
      开发版: 5.x-dev, 同上,但已经有最低要求5.3的命令
      支持
      5,6,7
      4, 不支持Windows
    • 网站管理(安装,升级)
      项目管理(模块,主题,解决方案配置包,翻译)
      核心管理(缓存,计划任务,用户,变量表)
      数据库管理(查询,更新,备份,迁移)
      编写脚本程序
      可扩展性,使得Drush可以做的更多
      Drush改变了网站的开发方式和维护方式
      对Drush了解越多,用Drush能做的事情就越多。
      Drush 能做什么
    • 程序员
      网站管理员
      项目经理
      架构师
      任何人
      谁需要用Drush
    • http://drush.ws
      Drush官方网站
      http://drupal.org/project/drush
      Drush在Drupal的项目地址
      http://drupal.org/documentation/modules/drush
      Drush在Drupal的文档
      http://drupal.org/taxonomy/term/4654
      与Drush有关的模块
      Google.com
      与Drush有关的文章非常非常的多
      Drush 相关资源
    • Drush命令执行路径
      drush_main()
      drush_dispatch()
      drush_command();
      drush_invoke()
      _drush_invoke_args
      自定义命令写法
      命令文件,可以放在很多地方
      MODULE.drush.inc
      hook
      MODULE_drush_command
      MODULE_drush_help
      MODULE_drush_init
      MODULE_drush_load
      Drush 原理
    • 执行流程
      hook_drush_init()
      drush_COMMAND_init()
      drush_hook_COMMAND_validate()
      drush_hook_pre_COMMAND()
      drush_hook_COMMAND()
      drush_hook_post_COMMAND()
      drush_hook_post_COMMAND_rollback()
      drush_hook_COMMAND_rollback()
      drush_hook_pre_COMMAND_rollback()
      drush_hook_COMMAND_validate_rollback()
      hook_drush_exit()
      Drush原理
    • BOOTSTRAP流程
      define('DRUSH_BOOTSTRAP_DRUSH', 0);
      define('DRUSH_BOOTSTRAP_DRUPAL_ROOT', 1);
      define('DRUSH_BOOTSTRAP_DRUPAL_SITE', 2);
      define('DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION', 3);
      define('DRUSH_BOOTSTRAP_DRUPAL_DATABASE', 4);
      define('DRUSH_BOOTSTRAP_DRUPAL_FULL', 5);
      define('DRUSH_BOOTSTRAP_DRUPAL_LOGIN', 6);
      Drush原理
    • 配置文件
      ~/.drush/drushrc.php
      别名机制
      ~/.drush/aliases.drushrc.php
      $aliases['dev'] = array(
      'root' => '/path/to/drupal',
      'uri' => 'dev.mydrupalsite.com',
      );
      $ drush @dev cc
      作为选项
      作为参数
      policy机制
      Drush原理
    • 执行命令
      $ drush [OPTIONS] command [ARGUMENTS]
      写PHP脚本
      #! /usr/bin/envdrush
      #! /path/to drush @d6.dev –user=1 php-script
      Drush 应用
    • 构建开发和测试环境
      dev<->staging<->www
      $ svn up / git pull
      $ drush sql-sync --structure-tables-key=custom --no-cache @live @dev --sanitize
      $ drush rsync @staging:%files/ @live:%files
      $ drush updatedb
      $ drush features-rever t
      构建网站开发解决方案
      drush make
      构建可重用功能特性
      drush + features
      Drush 应用
    • 集成第三方扩展命令
      backup_migrate
      drush_make
      node_export
      devel
      features
      dbtng_migrator
      drush_extras
      module_builder
      drush_views
      Drush应用
    • api = 2
      core = 6.x
      projects[drupal][version] = "6.22"
      ; Modules
      projects[views][subdir] = "contrib"
      projects[views][version] = "2.11"
      projects[cck][subdir] = "contrib"
      projects[cck][version] = "2.8
      Drush makefile 示例
    • ; CKEditor
      libraries[ckeditor][download][type]= "get"
      libraries[ckeditor][download][url] = "http://download.cksource.com/CKEditor/CKEditor/CKEditor%203.4/ckeditor_3.4.zip"
      libraries[ckeditor][directory_name] = "ckeditor"
      libraries[ckeditor][destination] = "libraries"
      Drush makefile 示例
    • drush5
      runserver
      site-ssh
      Issue queue commands
      $ drush iq-info 1070558
      $ drush iq-apply-patch 1070558
      Node commands
      $ drush entity-show 1 
      $ drush entity-show 1 --json
      $ drush entity-edit 1
      $ drush entity-show 1 --json | drush entity-create
      Parallelization
      Drush未来
    • 演示!
    • 问题?
    • 谢谢大家!