---
url: 'https://dxpr.com/zh-hans/hc/documentation/learn-drupal/getting-started/updating-drupal-modules-and-themes-composer'
title: '使用 Composer 更新 Drupal 模块和主题 | DXPR'
author:
  name: Jurriaan
  url: 'https://dxpr.com/users/jurriaan'
date: '2026-10-24T08:17:30+00:00'
copyright: 'Copyright DXPR. All rights reserved.'
type: article
summary: |-
  安装和更新 Drupal 10 网站的推荐方式是使用 Composer。要更新核心、所有过时的模块和主题、更新数据库并清空缓存：composer update "drupal/" --with-all-dependencies
  drush updatedb
  drush cache:rebuild要列出更新，请使用 Composer 的内置命令：
tags:
  - 'Aan de slag'
image: 'https://dxpr.com/themes/custom/dxpr_com/images/dxpr-share-card.jpg'
published: true
og:
  site_name: DXPR
  updated_time: '2026-10-24T08:17:30+0000'
  'image:alt': 'DXPR, powered by Drupal: AI-powered Drupal for marketers.'
schema:
  '@context': 'https://schema.org'
  '@graph':
    -
      mainEntity: {  }
    -
      '@type': TechArticle
      headline: '使用 Composer 更新 Drupal 模块和主题'
      description: |-
        安装和更新 Drupal 10 网站的推荐方式是使用 Composer。要更新核心、所有过时的模块和主题、更新数据库并清空缓存：composer update "drupal/" --with-all-dependencies
        drush updatedb
        drush cache:rebuild要列出更新，请使用 Composer 的内置命令：
      image:
        '@type': ImageObject
        url: 'https://dxpr.com/themes/custom/dxpr_com/images/dxpr-share-card.jpg'
        width: '1200'
        height: '630'
      datePublished: '2026-10-24T08:17:30+0000'
      dateModified: '2026-10-24T08:17:30+0000'
      author:
        '@type': Organization
        '@id': 'https://dxpr.com/#organization'
        name: DXPR
        url: 'https://dxpr.com/'
        logo:
          '@type': ImageObject
          url: 'https://dxpr.com/themes/custom/dxpr_com/dxpr-logo-dark.svg'
          width: '1348'
          height: '501'
      publisher:
        '@type': Organization
        '@id': 'https://dxpr.com/#organization'
        name: DXPR
        url: 'https://dxpr.com/'
        logo:
          '@type': ImageObject
          url: 'https://dxpr.com/themes/custom/dxpr_com/dxpr-logo-dark.svg'
          width: '1348'
          height: '501'
      mainEntityOfPage: 'https://dxpr.com/zh-hans/hc/documentation/learn-drupal/getting-started/updating-drupal-modules-and-themes-composer'
      articleSection: 'Aan de slag'
    -
      '@type': WebPage
      '@id': 'https://dxpr.com/zh-hans/hc/documentation/learn-drupal/getting-started/updating-drupal-modules-and-themes-composer'
      description: |-
        安装和更新 Drupal 10 网站的推荐方式是使用 Composer。要更新核心、所有过时的模块和主题、更新数据库并清空缓存：composer update "drupal/" --with-all-dependencies
        drush updatedb
        drush cache:rebuild要列出更新，请使用 Composer 的内置命令：
      breadcrumb:
        '@type': BreadcrumbList
        itemListElement:
          -
            '@type': ListItem
            position: 1
            name: 首页
            item: 'https://dxpr.com/zh-hans'
      publisher:
        '@type': Organization
        '@id': 'https://dxpr.com/#organization'
        name: DXPR
      inLanguage: zh-hans
---
[Help Center](/zh-hans/node/75)/[Documentation](/zh-hans/hc/documentation) /[Learn Drupal](/hc/documentation/learn-drupal) /[Aan de slag](/hc/documentation/learn-drupal/aan-de-slag) # 使用 Composer 更新 Drupal 模块和主题.

 Learn DrupalAan de slag

   ## In this guide

安装和更新 Drupal 10 网站的推荐方式是使用 Composer。

1. 要更新核心、所有过时的模块和主题、更新数据库并清空缓存：

    ```plaintext
    composer update "drupal/" --with-all-dependencies
    drush updatedb
    drush cache:rebuild
    ```
2. 要列出更新，请使用 Composer 的内置命令：

    ```plaintext
    composer outdated "drupal/*"
    ```
3. 要列出安全更新，请使用 Drush：

    ```plaintext
    drush pm:security
    ```
4. 要更新指定的模块或主题，请使用以下 Composer 命令：

    ```plaintext
    composer update drupal/modulename --with-all-dependencies
    ```
5. 要进行大版本升级（例如从 1.x 到 2.x），请使用以下 Composer 命令，并根据需要替换新的主版本号：

    ```plaintext
    composer require drupal/modulename:^2.0
    ```
6. 更新完成后，运行所有数据库更新，重建缓存，并导出可能已更改的配置，通过`--diff`：

    ```plaintext
    drush updatedb
    drush cache:rebuild
    drush config:export --diff
    ```