Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .ddev/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: drupalcz
type: drupal9
docroot: docroot
php_version: "8.1"
webserver_type: apache-fpm
router_http_port: "80"
router_https_port: "443"
xdebug_enabled: false
additional_hostnames: []
additional_fqdns: []
database:
type: mariadb
version: "10.11"
use_dns_when_possible: true
composer_version: "2"
web_environment: []

hooks:
post-start:
- exec: scripts/create-settings.sh
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ local.blt.yml
.lando.local.yml
/docroot/themes/custom/dcz_theme/config_local.json

# DDEV
.ddev/.homeadditions
.ddev/.gitignore
.ddev/import-db
.ddev/db_snapshots
.ddev/.dbirc
.ddev/.bash_history

# Ignore drupal core.
docroot/core

Expand Down
167 changes: 167 additions & 0 deletions DDEV_MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# Migrating from Lando to DDEV

This document explains how to migrate from Lando to DDEV for local development.

## Prerequisites

1. Install DDEV: https://ddev.readthedocs.io/en/stable/#installation
2. Stop and remove your Lando environment (optional, but recommended to free resources):
```
lando stop
lando destroy
```

## Migration Steps

### 1. Start DDEV

```bash
ddev start
```

This will:
- Download required Docker images
- Create containers for web server, database, and other services
- Run the `scripts/create-settings.sh` hook to create local settings file

### 2. Install Drupal

If you're setting up from scratch:

```bash
ddev drush si minimal --existing-config
```

### 3. Import Content (Optional)

If you want default content for development:

```bash
ddev drush dcdi --force update
ddev drush cr
```

### 4. Get Login Link

```bash
ddev drush uli
```

### 5. Access Your Site

Your site will be available at:
- http://drupalcz.ddev.site
- https://drupalcz.ddev.site (if mkcert is installed)

## Useful DDEV Commands

| Lando Command | DDEV Equivalent |
|---------------|-----------------|
| `lando start` | `ddev start` |
| `lando stop` | `ddev stop` |
| `lando poweroff` | `ddev poweroff` |
| `lando drush <command>` | `ddev drush <command>` |
| `lando composer <command>` | `ddev composer <command>` |
| `lando ssh` | `ddev ssh` |
| `lando db-import <file>` | `ddev import-db --src=<file>` |
| `lando db-export` | `ddev export-db` |
| `lando logs` | `ddev logs` |

## Database Migration

If you have an existing database in Lando that you want to migrate:

1. Export from Lando:
```bash
lando db-export database.sql.gz
```

2. Stop Lando and start DDEV:
```bash
lando stop
ddev start
```

3. Import into DDEV:
```bash
ddev import-db --src=database.sql.gz
ddev drush cr
```

## Files Migration

If you have user-uploaded files:

1. Your files in `docroot/sites/default/files/` will remain in place
2. Private files are now expected at `/var/www/html/private` inside the container

## Frontend Development

The original Lando setup included Node.js for theme development. For DDEV, you have two options:

### Option 1: Use DDEV's Node service (Recommended)

Add to `.ddev/config.yaml`:
```yaml
web_extra_daemons:
- name: "node"
command: "/var/www/html/docroot/themes/custom/dcz_theme && npm install && npm run watch"
directory: /var/www/html/docroot/themes/custom/dcz_theme
```

### Option 2: Use Node.js on your host machine

Install Node.js locally and run:
```bash
cd docroot/themes/custom/dcz_theme
npm install
npm run watch
```

## Differences from Lando

- **Database host**: Changed from `database` to `db`
- **Database credentials**: All are `db` (name, username, password)
- **Project URL**: Changed from `*.lndo.site` to `*.ddev.site`
- **Mailhog**: Available at http://drupalcz.ddev.site:8025
- **PHP version**: 7.4 (same as Lando)
- **Web server**: Apache (same as Lando)

## Custom Settings Structure

This project uses a custom settings file structure instead of DDEV's default `settings.ddev.php`:

1. **Main settings**: `docroot/sites/default/settings.php` includes `docroot/sites/default/settings/includes.settings.php`
2. **DDEV detection**: `includes.settings.php` detects DDEV via the `IS_DDEV_PROJECT` environment variable
3. **DDEV settings**: When DDEV is detected, it loads `docroot/sites/default/settings/ddev.settings.php`
4. **Local overrides**: Finally, it loads `docroot/sites/default/settings/local.settings.php` if it exists

This structure allows the same codebase to work with Lando, DDEV, Acquia Cloud, and other environments without modification.

## Troubleshooting

### Clear cache if you have issues
```bash
ddev drush cr
```

### Restart DDEV
```bash
ddev restart
```

### Check DDEV status
```bash
ddev describe
```

### View logs
```bash
ddev logs
```

## Additional Resources

- DDEV Documentation: https://ddev.readthedocs.io/
- DDEV Drupal Quickstart: https://ddev.readthedocs.io/en/stable/users/quickstart/#drupal

82 changes: 82 additions & 0 deletions DDEV_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# DDEV Migration Summary

## Files Created

1. **`.ddev/config.yaml`** - Main DDEV configuration file
- Configures Drupal 9, PHP 7.4, Apache, MariaDB 10.4
- Disables DDEV's automatic settings management (we use custom structure)
- Includes post-start hook to create local settings file

2. **`docroot/sites/default/settings/ddev.settings.php`** - DDEV-specific settings
- Database connection configuration (db/db/db on host 'db')
- Development-friendly settings (caching disabled, update access enabled)
- Config split configuration for development
- Private files path and other Drupal settings

3. **`DDEV_MIGRATION.md`** - Migration guide
- Step-by-step instructions for migrating from Lando to DDEV
- Command reference table
- Database and files migration instructions
- Troubleshooting tips

## Files Modified

1. **`docroot/sites/default/settings/includes.settings.php`**
- Added DDEV environment detection using `IS_DDEV_PROJECT` environment variable
- Loads `settings/ddev.settings.php` when running in DDEV

2. **`.gitignore`**
- Added DDEV-specific ignore patterns

3. **`README.md`**
- Added DDEV setup instructions
- Added reference to migration guide

## How It Works

### Settings Loading Chain:
1. Drupal loads `docroot/sites/default/settings.php`
2. Which includes `docroot/sites/default/settings/includes.settings.php`
3. `includes.settings.php` checks for environment:
- If `IS_DDEV_PROJECT=true` → loads `settings/ddev.settings.php`
- If `LANDO_APP_NAME` exists → loads `settings/lando.settings.php`
- If `AH_SITE_ENVIRONMENT` exists → loads Acquia Cloud settings
4. Finally loads `settings/local.settings.php` for any local overrides

### Database Configuration:
- **Host**: `db` (DDEV's database container)
- **Database**: `db`
- **Username**: `db`
- **Password**: `db`
- **Port**: `3306`

This setup ensures that:
- Both Lando and DDEV can work simultaneously (different environment detection)
- No code changes needed when switching between environments
- Settings are organized and maintainable
- DDEV doesn't interfere with the custom settings structure

## Quick Start

```bash
# Start DDEV
ddev start

# Check status
ddev drush status

# Get login link
ddev drush uli

# Access site at:
# http://drupalcz.ddev.site
```

## Note on settings.ddev.php

DDEV normally auto-generates a `settings.ddev.php` file in `docroot/sites/default/`.
This project uses a custom settings structure, so we:
- Set `disable_settings_management: true` in `.ddev/config.yaml`
- Use `docroot/sites/default/settings/ddev.settings.php` instead
- This allows better organization and multi-environment support

16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ Branch | Build status | Dev site | HTTP Basic auth
* .travis.yml - Travis CI test suite configuration.

## Requirements
### Pokud používáte DDEV
* Nainstalujte si DDEV, https://ddev.readthedocs.io/en/stable/#installation
* V adresáři projektu spusťte DDEV

ddev start

* Po prvním spuštění nainstalujte Drupal:

ddev drush si minimal --existing-config

* Přihlaste se:

ddev drush uli

* **Pokud migrujete z Lando**, viz [DDEV_MIGRATION.md](DDEV_MIGRATION.md)

### Pokud používáte Lando
* Nainstalujte si Lando, https://docs.devwithlando.io/installation/system-requirements.html
* V adresáři projektu spusťte Lando
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
token: ""
hostname: ""
twostep:
enabled: FALSE
channel: ""
message: "!email has requested an invitation to the Slack team. Click the following link to approve: !url"
6 changes: 6 additions & 0 deletions docroot/modules/custom/slack_invite/slack_invite.info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name: Slack Invite
type: module
description: 'Invite your users to your slack team'
package: Custom
core_version_requirement: ^9 || ^10 || ^11

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
slack_invite.settingss:
title: 'Slack Invite'
parent: system.admin_config_services
description: 'Slack Invite Settings'
route_name: slack_invite.settings
42 changes: 42 additions & 0 deletions docroot/modules/custom/slack_invite/slack_invite.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* @file
* Primarily Drupal hooks and global API functions to manipulate slack invite.
*
* This is the main module file for Slack Invite.
*/


define('SLACK_INVITE_ALREADY_IN_TEAM', 'already_in_team');
define('SLACK_INVITE_SENT_RECENTLY', 'sent_recently');
define('SLACK_INVITE_ALREADY_INVITED', 'already_invited');

/**
* Sends slack invite to email address.
*/
function _slack_invite_send_invite($email) {
$team_hostname = variable_get('slack_invite_hostname', '');
$api_url = "https://{$team_hostname}.slack.com/api/users.admin.invite?t=" . time();

$data = [
'_attempts' => 1,
'email' => $email,
'set_active' => 'true',
'token' => variable_get('slack_invite_token', ''),
];

$data['channels'] = variable_get('slack_invite_channels', '');
if (empty($data['channels'])) {
unset($data['channels']);
}

$data = drupal_http_build_query($data);
$options = [
'method' => 'POST',
'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
'data' => $data,
];

return drupal_http_request("{$api_url}", $options);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
administer slack invite:
title: 'Administer Slack Invite Settings.'
description: 'Administer the Slack Invite Settings.'

approve slack invite:
title: 'Approve Slack Invites.'
description: 'Approve two-step Slack invitations.'
15 changes: 15 additions & 0 deletions docroot/modules/custom/slack_invite/slack_invite.routing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
slack_invite.settings:
path: '/admin/config/services/slack-invite'
defaults:
_form: 'Drupal\slack_invite\Form\SlackInviteSettingsForm'
_title: 'Slack Invite Settings'
requirements:
_permission: 'administer slack invite'

slack_invite.twostep:
path: '/slack_invite/{email}/{token}'
defaults:
_form: 'Drupal\slack_invite\Form\SlackInviteTwoStepApproveForm'
_title: 'Approve Slack invitation'
requirements:
_custom_access: 'Drupal\slack_invite\Form\SlackInviteTwoStepApproveForm::access'
Loading