github.com/drud/ddev@v1.21.5-alpha1.0.20230226034409-94fcc4b94453/docs/content/users/quickstart.md (about)

     1  # CMS Quickstarts
     2  
     3  While the generic `php` project type is [ready to go](./project.md) with any CMS or framework, DDEV offers project types for more easily working with popular platforms and content management systems:
     4  
     5  === "Craft CMS"
     6  
     7      ## Craft CMS
     8  
     9      Start a new [Craft CMS](https://craftcms.com) project or retrofit an existing one.
    10  
    11      !!!tip "Compatibility"
    12          The `craft` project type was added to DDEV in version [1.21.2](https://github.com/drud/ddev/releases/tag/v1.21.2). Check your current version with the `ddev version` command, and [upgrade](../users/usage/faq.md#how-can-i-updateupgrade-ddev) if necessary!
    13  
    14      Environment variables will be automatically added to your `.env` file to simplify the first boot of a project. For _new_ installations, this means the default URL and database connection settings displayed during installation can be used without modification. If _existing_ projects expect environment variables to be named in a particular way, you are welcome to rename them.
    15  
    16      === "New projects"
    17  
    18          New Craft CMS projects can be created from the official [starter project](https://github.com/craftcms/craft) using DDEV’s [`composer create` command](../users/usage/commands.md#composer):
    19  
    20          ```bash
    21          # Create a project directory and move into it:
    22          mkdir my-craft-project
    23          cd my-craft-project
    24  
    25          # Set up the DDEV environment:
    26          ddev config --project-type=craftcms --docroot=web --create-docroot
    27  
    28          # Boot the project and install the starter project:
    29          ddev start
    30          ddev composer create -y --no-scripts craftcms/craft
    31  
    32          # Run the Craft installer:
    33          ddev craft install
    34          ddev launch
    35          ```
    36  
    37          Third-party starter projects can by used the same way—just substitute the package name when running `ddev composer create`.
    38  
    39      === "Existing projects"
    40  
    41          You can start using DDEV with an existing project, too—just make sure you have a database backup handy!
    42  
    43          ```bash
    44          # Clone an existing repository (or navigate to a local project directory):
    45          git clone https://github.com/example/example-site my-craft-project
    46          cd my-craft-project
    47  
    48          # Set up the DDEV environment:
    49          ddev config --project-type=craftcms
    50  
    51          # Boot the project and install Composer packages:
    52          ddev start
    53          ddev composer install
    54  
    55          # Import a database backup and open the site in your browser:
    56          ddev import-db --src=/path/to/db.sql.gz
    57          ddev launch
    58          ```
    59  
    60      !!!tip "Upgrading or using a generic project type?"
    61          If you previously set up DDEV in a Craft project using the generic `php` project type, update the `type:` setting in `.ddev/config.yaml` to `craftcms`, then run [`ddev restart`](../users/usage/commands.md#restart) apply the changes.
    62  
    63      ### Running Craft in a Sub-directory
    64  
    65      In order for `ddev craft` to work when Craft is installed in a sub-directory, you will need to change the location of the `craft` executable by providing the `CRAFT_CMD_ROOT` environment variable to the web container. For example, if the installation lives in `my-craft-project/app`, you would run `ddev config --web-environment-add=CRAFT_CMD_ROOT=./app`. `CRAFT_CMD_ROOT` defaults to `./`, the project root directory. Run `ddev restart` to apply the change.
    66  
    67      More information about customizing the environment and persisting configuration can be found in [Providing Custom Environment Variables to a Container](https://ddev.readthedocs.io/en/latest/users/extend/customization-extendibility/#providing-custom-environment-variables-to-a-container).
    68  
    69      !!!tip "Installing Craft"
    70          Read more about installing Craft in the [official documentation](https://craftcms.com/docs).
    71  
    72  === "Drupal"
    73  
    74      ## Drupal
    75  
    76      === "Drupal 10"
    77  
    78          ### Drupal 10 via Composer
    79  
    80          [Drupal 10](https://www.drupal.org/about/10) is fully supported by DDEV.
    81  
    82          ```bash
    83          mkdir my-drupal10-site
    84          cd my-drupal10-site
    85          ddev config --project-type=drupal10 --docroot=web --create-docroot
    86          ddev start
    87          ddev composer create drupal/recommended-project
    88          ddev composer require drush/drush
    89          ddev drush site:install --account-name=admin --account-pass=admin -y
    90          ddev drush uli
    91          ddev launch
    92          ```
    93  
    94      === "Drupal 9"
    95  
    96          ### Drupal 9 via Composer
    97  
    98          ```bash
    99          mkdir my-drupal9-site
   100          cd my-drupal9-site
   101          ddev config --project-type=drupal9 --docroot=web --create-docroot
   102          ddev start
   103          ddev composer create "drupal/recommended-project:^9"
   104          ddev composer require drush/drush
   105          ddev drush site:install --account-name=admin --account-pass=admin -y
   106          ddev drush uli
   107          ddev launch
   108          ```
   109  
   110      === "Drupal 6/7"
   111  
   112          ### Drupal 6/7
   113  
   114          ```bash
   115          git clone https://github.com/example/my-drupal-site
   116          cd my-drupal-site
   117          ddev config # Follow the prompts to select type and docroot
   118          ddev start
   119          ddev launch /install.php
   120          ```
   121  
   122          Drupal 7 doesn’t know how to redirect from the front page to `/install.php` if the database is not set up but the settings files *are* set up, so launching with `/install.php` gets you started with an installation. You can also `drush site-install`, then `ddev exec drush site-install --yes`.
   123  
   124          See [Importing a Database](#importing-a-database).
   125  
   126      === "Git Clone"
   127  
   128          ### Git Clone
   129  
   130          ```bash
   131          git clone https://github.com/example/my-drupal-site
   132          cd my-drupal-site
   133          ddev config # Follow the prompts to set Drupal version and docroot
   134          ddev composer install # If a composer build
   135          ddev launch
   136          ```
   137  
   138      === "Backdrop"
   139  
   140          ### Backdrop
   141  
   142          To get started with [Backdrop](https://backdropcms.org), clone the project repository and navigate to the project directory.
   143  
   144          ```bash
   145          git clone https://github.com/example/example-site
   146          cd example-site
   147          ddev config
   148          ddev start
   149          ddev launch
   150          ```
   151  
   152  === "Laravel"
   153  
   154      ## Laravel
   155  
   156      === "Laravel"
   157  
   158          Use a new or existing Composer project, or clone a Git repository.
   159  
   160          The Laravel project type can be used for [Lumen](https://lumen.laravel.com/) just as it can for Laravel. DDEV automatically updates or creates the `.env` file with the database information.
   161  
   162          === "Composer"
   163              ```bash
   164              mkdir my-laravel-app
   165              cd my-laravel-app
   166              ddev config --project-type=laravel --docroot=public --create-docroot
   167              ddev composer create --prefer-dist --no-install --no-scripts laravel/laravel
   168              ddev composer install
   169              ddev exec "php artisan key:generate"
   170              ddev launch
   171              ```
   172          === "Git Clone"
   173              ```bash
   174              git clone <your-laravel-repo>
   175              cd <your-laravel-project>
   176              ddev config --project-type=laravel --docroot=public --create-docroot
   177              ddev start
   178              ddev composer install
   179              ddev exec "php artisan key:generate"
   180              ddev launch
   181              ```
   182  
   183      === "Statamic"
   184  
   185          Use a new or existing Composer project, or clone a Git repository.
   186  
   187          The Laravel project type can be used for [Statamic](https://statamic.com/) just as it can for Laravel. DDEV automatically updates or creates the `.env` file with the database information.
   188  
   189          === "Composer"
   190              ```bash
   191              mkdir my-statamic-app
   192              cd my-statamic-app
   193              ddev config --project-type=laravel --docroot=public --create-docroot
   194              ddev composer create --prefer-dist --no-install --no-scripts statamic/statamic
   195              ddev composer install
   196              ddev exec "php artisan key:generate"
   197              ddev launch
   198              ```
   199          === "Git Clone"
   200              ```bash
   201              git clone <your-statamic-repo>
   202              cd <your-statamic-project>
   203              ddev config --project-type=laravel --docroot=public --create-docroot
   204              ddev start
   205              ddev composer install
   206              ddev exec "php artisan key:generate"
   207              ddev launch
   208              ```
   209  
   210  === "Magento"
   211  
   212      ## Magento 2
   213  
   214      Normal details of a Composer build for Magento 2 are on the [Magento 2 site](https://devdocs.magento.com/guides/v2.4/install-gde/composer.html). You must have a public and private key to install from Magento’s repository. When prompted for “username” and “password” in `composer create`, it’s asking for your public and private keys.
   215  
   216      ```bash
   217      mkdir ddev-magento2 && cd ddev-magento2
   218      ddev config --project-type=magento2 --php-version=8.1 --docroot=pub --create-docroot --disable-settings-management
   219      ddev get drud/ddev-elasticsearch
   220      ddev start
   221      ddev composer create --repository=https://repo.magento.com/ magento/project-community-edition -y
   222      rm -f app/etc/env.php
   223      # Change the base-url below to your project's URL
   224      ddev magento setup:install --base-url='https://ddev-magento2.ddev.site/' --cleanup-database --db-host=db --db-name=db --db-user=db --db-password=db --elasticsearch-host=elasticsearch --admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com --admin-user=admin --admin-password=admin123 --language=en_US
   225      ddev magento deploy:mode:set developer
   226      ddev magento module:disable Magento_TwoFactorAuth
   227      ddev config --disable-settings-management=false
   228      ```
   229  
   230      Change the admin name and related information is needed.
   231  
   232      You may want to add the [Magento 2 Sample Data](https://devdocs.magento.com/guides/v2.4/install-gde/install/sample-data-after-composer.html) with `ddev magento sampledata:deploy && ddev magento setup:upgrade`.
   233  
   234      Magento 2 is a huge codebase, and we recommend [using Mutagen for performance](install/performance.md#using-mutagen) on macOS and traditional Windows.
   235  
   236      ## OpenMage/Magento 1
   237  
   238      1. Download OpenMage from [release page](https://github.com/OpenMage/magento-lts/releases).
   239      2. Make a directory for it, for example `mkdir ~/workspace/OpenMage` and change to the new directory `cd ~/workspace/OpenMage`.
   240      3. Run [`ddev config`](../users/usage/commands.md#config) and accept the defaults.
   241      4. Install sample data. (See below.)
   242      5. Run [`ddev start`](../users/usage/commands.md#start).
   243      6. Follow the URL to the base site.
   244  
   245      You may want the [Magento 1 Sample Data](https://github.com/Vinai/compressed-magento-sample-data) for experimentation:
   246  
   247      * Download Magento [1.9.2.4 Sample Data](https://github.com/Vinai/compressed-magento-sample-data/raw/master/compressed-magento-sample-data-1.9.2.4.tgz).
   248      * Extract the download:
   249          `tar -zxf ~/Downloads/compressed-magento-sample-data-1.9.2.4.tgz --strip-components=1`
   250      * Import the example database `magento_sample_data_for_1.9.2.4.sql` with `ddev import-db --src=magento_sample_data_for_1.9.2.4.sql` to database **before** running OpenMage install.
   251  
   252      OpenMage is a huge codebase, and we recommend [using Mutagen for performance](install/performance.md#using-mutagen) on macOS and traditional Windows.
   253  
   254  === "Moodle"
   255  
   256      ## Moodle
   257  
   258      ```bash
   259      ddev config --composer-root=public --create-docroot --docroot=public --webserver-type=apache-fpm
   260      ddev start
   261      ddev composer create moodle/moodle -y
   262      ddev exec 'php public/admin/cli/install.php --non-interactive --agree-license --wwwroot=$DDEV_PRIMARY_URL --dbtype=mariadb --dbhost=db --dbname=db --dbuser=db --dbpass=db --fullname="DDEV Moodle Demo" --shortname=Demo --adminpass=password'
   263      ddev launch /login
   264      ```
   265  
   266      In the web browser, log into your account using `admin` and `password`.
   267  
   268      Visit the [Moodle Admin Quick Guide](https://docs.moodle.org/400/en/Admin_quick_guide) for more information.
   269  
   270      !!!tip
   271          Moodle relies on a periodic cron job—don’t forget to set that up! See [drud/ddev-cron](https://github.com/drud/ddev-cron).
   272  
   273  === "Shopware"
   274  
   275      ## Shopware 6
   276  
   277      You can set up a Shopware 6 environment many ways, we recommend the following technique:
   278  
   279      ```bash
   280      git clone --branch=6.4 https://github.com/shopware/production my-shopware6
   281      cd my-shopware6
   282      ddev config --project-type=shopware6 --docroot=public
   283      ddev start
   284      ddev composer install --no-scripts
   285      # During system:setup you may have to enter the Database user (db), Database password (db)
   286      # Database host (db) and Database name (db).
   287      ddev exec bin/console system:setup --database-url=mysql://db:db@db:3306/db --app-url='${DDEV_PRIMARY_URL}'
   288      ddev exec bin/console system:install --create-database --basic-setup
   289      ddev launch /admin
   290      ```
   291  
   292      Log into the admin site (`/admin`) using the web browser. The default credentials are username `admin` and password `shopware`. You can use the web UI to install sample data or accomplish many other tasks.
   293  
   294      For more advanced tasks like adding elasticsearch, building and watching storefront and administration, see [susi.dev](https://susi.dev/ddev-shopware-6).
   295  
   296  === "TYPO3"
   297  
   298      ## TYPO3
   299  
   300      === "Composer"
   301  
   302          ### Composer
   303  
   304          ```bash
   305          mkdir my-typo3-site
   306          cd my-typo3-site
   307          ddev config --project-type=typo3 --docroot=public --create-docroot --php-version 8.1
   308          ddev start
   309          ddev composer create "typo3/cms-base-distribution"
   310          ddev exec touch public/FIRST_INSTALL
   311          ddev launch
   312          ```
   313  
   314      === "Git Clone"
   315  
   316          ### Git Clone
   317  
   318          ```bash
   319          git clone https://github.com/example/example-site
   320          cd example-site
   321          ddev config --project-type=typo3 --docroot=public --create-docroot --php-version 8.1
   322          ddev composer install
   323          ddev restart
   324          ddev exec touch public/FIRST_INSTALL
   325          ddev launch
   326          ```
   327  
   328  === "WordPress"
   329  
   330      ## WordPress
   331  
   332      There are several easy ways to use DDEV with WordPress:
   333  
   334      === "WP-CLI"
   335  
   336          ### WP-CLI
   337  
   338          DDEV has built-in support for [WP-CLI](https://wp-cli.org/), the command-line interface for WordPress.
   339  
   340          ```bash
   341          mkdir my-wp-site
   342          cd my-wp-site/
   343  
   344          # Create a new DDEV project inside the newly-created folder
   345          # (Primary URL automatically set to `https://<folder>.ddev.site`)
   346          ddev config --project-type=wordpress
   347          ddev start
   348  
   349          # Download WordPress
   350          ddev wp core download
   351  
   352          # Launch in browser to finish installation
   353          ddev launch
   354  
   355          # OR use the following installation command
   356          # (we need to use single quotes to get the primary site URL from `.ddev/config.yaml` as variable)
   357          ddev wp core install --url='$DDEV_PRIMARY_URL' --title='New-WordPress' --admin_user=admin --admin_email=admin@example.com --prompt=admin_password
   358  
   359          # Launch WordPress admin dashboard in your browser
   360          ddev launch wp-admin/
   361          ```
   362  
   363      === "Bedrock"
   364  
   365          ### Bedrock
   366  
   367          [Bedrock](https://roots.io/bedrock/) is a modern, Composer-based installation in WordPress:
   368  
   369          ```bash
   370          mkdir my-wp-bedrock-site
   371          cd my-wp-bedrock-site
   372          ddev config --project-type=wordpress --docroot=web --create-docroot
   373          ddev start
   374          ddev composer create roots/bedrock
   375          ```
   376  
   377          Update the `.env` file in the project root for Bedrock’s WordPress configuration convention:
   378  
   379          ```
   380          DB_NAME=db
   381          DB_USER=db
   382          DB_PASSWORD=db
   383          DB_HOST=db
   384          WP_HOME=${DDEV_PRIMARY_URL}
   385          WP_SITEURL=${WP_HOME}/wp
   386          WP_ENV=development
   387          ```
   388  
   389          You can then run [`ddev start`](../users/usage/commands.md#start) and [`ddev launch`](../users/usage/commands.md#launch).
   390  
   391          For more details, see [Bedrock installation](https://docs.roots.io/bedrock/master/installation/).
   392  
   393      === "Git Clone"
   394  
   395          ### Git Clone
   396  
   397          To get started using DDEV with an existing WordPress project, clone the project’s repository. Note that the git URL shown here is just an example.
   398  
   399          ```bash
   400          git clone https://github.com/example/example-site.git
   401          cd example-site
   402          ddev config
   403          ```
   404  
   405          You’ll see a message like:
   406  
   407          ```php
   408          An existing user-managed wp-config.php file has been detected!
   409          Project DDEV settings have been written to:
   410  
   411          /Users/rfay/workspace/bedrock/web/wp-config-ddev.php
   412  
   413          Please comment out any database connection settings in your wp-config.php and
   414          add the following snippet to your wp-config.php, near the bottom of the file
   415          and before the include of wp-settings.php:
   416  
   417          // Include for DDEV-managed settings in wp-config-ddev.php.
   418          $ddev_settings = dirname(__FILE__) . '/wp-config-ddev.php';
   419          if (is_readable($ddev_settings) && !defined('DB_USER')) {
   420            require_once($ddev_settings);
   421          }
   422  
   423          If you don't care about those settings, or config is managed in a .env
   424          file, etc, then you can eliminate this message by putting a line that says
   425          // wp-config-ddev.php not needed
   426          in your wp-config.php
   427          ```
   428  
   429          So just add the suggested include into your `wp-config.php`, or take the workaround shown.
   430  
   431          Now start your project with [`ddev start`](../users/usage/commands.md#start).
   432  
   433          Quickstart instructions regarding database imports can be found under [Importing a database](#importing-a-database).
   434  
   435  ## Configuration Files
   436  
   437  The [`ddev config`](../users/usage/commands.md#config) command attempts to create a CMS-specific settings file pre-populated with DDEV credentials.
   438  
   439  For **Drupal** and **Backdrop**, DDEV settings are written to a DDEV-managed file, `settings.ddev.php`. The `ddev config` command will ensure these settings are included in your `settings.php` through the following steps:
   440  
   441  - Write DDEV settings to `settings.ddev.php`.
   442  - If no `settings.php` file exists, create one that includes `settings.ddev.php`.
   443  - If a `settings.php` file already exists, ensure that it includes `settings.ddev.php`, modifying `settings.php` to write the include if necessary.
   444  
   445  For **Magento 1**, DDEV settings go into `app/etc/local.xml`.
   446  
   447  In **Magento 2**, DDEV settings go into `app/etc/env.php`.
   448  
   449  For **TYPO3**, DDEV settings are written to `AdditionalConfiguration.php`. If `AdditionalConfiguration.php` exists and is not managed by DDEV, it will not be modified.
   450  
   451  For **WordPress**, DDEV settings are written to a DDEV-managed file, `wp-config-ddev.php`. The `ddev config` command will attempt to write settings through the following steps:
   452  
   453  - Write DDEV settings to `wp-config-ddev.php`.
   454  - If no `wp-config.php` exists, create one that include `wp-config-ddev.php`.
   455  - If a DDEV-managed `wp-config.php` exists, create one that includes `wp-config.php`.
   456  - If a user-managed `wp-config.php` exists, instruct the user on how to modify it to include DDEV settings.
   457  
   458  You’ll know DDEV is managing a settings file when you see the comment below. Remove the comment and DDEV will not attempt to overwrite it! If you’re letting DDEV create its settings file, we recommended leaving this comment so DDEV can continue to manage it, and make any needed changes in another settings file.
   459  
   460  ```
   461  
   462  /**
   463   #ddev-generated: Automatically generated Drupal settings.php file.
   464   ddev manages this file and may delete or overwrite the file unless this comment is removed.
   465   */
   466  
   467  ```
   468  
   469  If you’re providing the `settings.php` or `wp-config.php` and DDEV is creating `settings.ddev.php` (or `wp-config-local.php`, `AdditionalConfig.php`, or similar), the main settings file must explicitly include the appropriate DDEV-generated settings file. Any changes you need should be included somewhere that loads after DDEV’s settings file, for example in Drupal’s `settings.php` _after_ `settings.ddev.php` is included. (See [Adding Configuration](#adding-configuration) below).
   470  
   471  !!!note "Completely Disabling Settings Management"
   472  
   473      If you do *not* want DDEV to create or manage settings files, set `disable_settings_management: true` in `.ddev/config.yaml` or run `ddev config --disable-settings-management`. Once you’ve done that, it’s solely up to you to manually edit those settings.
   474  
   475  ### Adding Configuration
   476  
   477  **Drupal and Backdrop**: In `settings.php`, enable loading `settings.local.php` after `settings.ddev.php` is included—creating a new one if it doesn’t already exist—and make changes there. Wrap with `if (getenv('IS_DDEV_PROJECT') == 'true')` as needed.
   478  
   479  **WordPress**: Load a `wp-config-local.php` after `wp-config-ddev.php`, and make changes there. Wrap with `if (getenv('IS_DDEV_PROJECT') == 'true')` as needed.
   480  
   481  ## Listing Project Information
   482  
   483  Run [`ddev list`](../users/usage/commands.md#list) or `ddev list --active-only` current projects.
   484  
   485  ```
   486  
   487  ➜  ddev list
   488  NAME          TYPE     LOCATION                   URL(s)                                STATUS
   489  d8git         drupal8  ~/workspace/d8git          <https://d8git.ddev.local>              running
   490                                                    <http://d8git.ddev.local>
   491  hobobiker     drupal6  ~/workspace/hobobiker.com                                        stopped
   492  
   493  ```
   494  
   495  ```
   496  
   497  ➜  ddev list --active-only
   498  NAME     TYPE     LOCATION             URL(s)                      STATUS
   499  drupal8  drupal8  ~/workspace/drupal8  <http://drupal8.ddev.site>   running
   500                                         <https://drupal8.ddev.site>
   501  
   502  ```
   503  
   504  You can also see more detailed information about a project by running [`ddev describe`](../users/usage/commands.md#describe) from its working directory. You can also run `ddev describe [project-name]` from any location to see the detailed information for a running project.
   505  
   506  ```
   507  NAME        TYPE     LOCATION                URL                           STATUS
   508  d9composer  drupal8  ~/workspace/d9composer  https://d9composer.ddev.site  running
   509  
   510  Project Information
   511  -------------------
   512  PHP version:    7.4
   513  MariaDB version 10.3
   514  
   515  URLs
   516  ----
   517  https://d9composer.ddev.site
   518  https://127.0.0.1:33232
   519  http://d9composer.ddev.site
   520  http://127.0.0.1:33233
   521  
   522  MySQL/MariaDB Credentials
   523  -------------------------
   524  Username: "db", Password: "db", Default database: "db"
   525  
   526  or use root credentials when needed: Username: "root", Password: "root"
   527  
   528  Database hostname and port INSIDE container: ddev-d9-db:3306
   529  To connect to db server inside container or in project settings files:
   530  mysql --host=ddev-d9-dbcomposer --user=db --password=db --database=db
   531  Database hostname and port from HOST: 127.0.0.1:33231
   532  To connect to mysql from your host machine,
   533  mysql --host=127.0.0.1 --port=33231 --user=db --password=db --database=db
   534  
   535  Other Services
   536  --------------
   537  MailHog (https):    https://d9composer.ddev.site:8026
   538  MailHog:            http://d9composer.ddev.site:8025
   539  phpMyAdmin (https): https://d9composer.ddev.site:8037
   540  phpMyAdmin:         http://d9composer.ddev.site:8036
   541  
   542  DDEV ROUTER STATUS: healthy
   543  ssh-auth status: healthy
   544  ```
   545  
   546  ## Removing Projects
   547  
   548  There are two ways to remove a project from DDEV’s listing.
   549  
   550  The first, the [`ddev delete`](../users/usage/commands.md#delete) command, is destructive. It removes the project from DDEV’s list, deletes its database, and removes the hostname entry from the hosts file:
   551  
   552  `ddev delete <projectname>`
   553  or
   554  `ddev delete --omit-snapshot <projectname>`
   555  
   556  If you simply don’t want the project to show up in [`ddev list`](../users/usage/commands.md#list) anymore, use [`ddev stop`](../users/usage/commands.md#stop)—which is nondestructive—to unlist the project until the next time you run [`ddev start`](../users/usage/commands.md#start) or [`ddev config`](../users/usage/commands.md#config):
   557  
   558  ```bash
   559  ddev stop --unlist <projectname>
   560  ```
   561  
   562  ## Importing Assets for An Existing Project
   563  
   564  An important aspect of local web development is the ability to have a precise local recreation of the project you’re working on, including up-to-date database contents and static assets like uploaded images and files. DDEV provides two commands to help with importing assets to your local environment.
   565  
   566  ### Importing a Database
   567  
   568  The [`ddev import-db`](../users/usage/commands.md#import-db) command imports the database for a project. Running this command will prompt you to specify the location of your database import. By default `ddev import-db` empties the default `db` database, then loads the provided dump file. Most people use it with command flags, like `ddev import-db --src=.tarballs/db.sql.gz`, but it can also prompt for the location of the dump if you only use `ddev import-db`:
   569  
   570  ```bash
   571  ddev import-db
   572  Provide the path to the database you wish to import.
   573  Import path:
   574  ~/Downloads/db.sql
   575  Importing database...
   576  Successfully imported database for drupal8
   577  ```
   578  
   579  #### Supported File Types
   580  
   581  Database imports can be any of the following file types:
   582  
   583  - Raw SQL Dump (`.sql`)
   584  - Gzipped SQL Dump (`.sql.gz`)
   585  - Xz’d SQL Dump (`.sql.xz`)
   586  - (Gzipped) Tarball Archive (`.tar`, `.tar.gz`, `.tgz`)
   587  - Zip Archive (`.zip`)
   588  - stdin
   589  
   590  If a Tarball Archive or Zip Archive is provided for the import, you’ll be prompted to specify a path within the archive to use for the import asset. The specified path should provide a raw SQL dump (`.sql`). In the following example, the database we want to import is named `data.sql` and resides at the top level of the archive:
   591  
   592  ```bash
   593  ddev import-db
   594  Provide the path to the database you wish to import.
   595  Import path:
   596  ~/Downloads/site-backup.tar.gz
   597  You provided an archive. Do you want to extract from a specific path in your archive? You may leave this blank if you wish to use the full archive contents
   598  Archive extraction path:
   599  data.sql
   600  Importing database...
   601  A settings file already exists for your application, so ddev did not generate one.
   602  Run 'ddev describe' to find the database credentials for this application.
   603  Successfully imported database for drupal8
   604  ```
   605  
   606  #### Non-Interactive Usage
   607  
   608  If you want to use the [`import-db`](../users/usage/commands.md#import-db) command without answering prompts, you can use the `--src` flag to provide the path to the import asset. If you’re importing an archive and wish to specify the path within the archive to extract, you can use the `--extract-path` flag in conjunction with the `--src` flag. Examples:
   609  
   610  ```bash
   611  ddev import-db --src=/tmp/mydb.sql.gz
   612  gzip -dc /tmp/mydb.sql.gz | ddev import-db
   613  ddev import-db <mydb.sql
   614  ```
   615  
   616  #### Database Import Notes
   617  
   618  - Importing from a dump file via stdin will not show progress because there’s no way the import can know how far along through the import it has progressed.
   619  - Use `ddev import-db --target-db <some_database>` to import to a non-default database (other than the default `db` database). This will create the database if it doesn’t already exist.
   620  - Use `ddev import-db --no-drop` to import without first emptying the database.
   621  - If a database already exists and the import does not specify dropping tables, the contents of the imported dumpfile will be _added_ to the database. Most full database dumps do a table drop and create before loading, but if yours does not, you can drop all tables with `ddev stop --remove-data` before importing.
   622  - If imports are stalling or failing, make sure you have plenty of unused space (see [#3360](https://github.com/drud/ddev/issues/3360)). DDEV has no problems importing large (2G+) databases, but importing requires lots of space. DDEV will show a warning on startup if unused space is getting low.