Learning with DrupalXpert
Guide through the essential steps to set up, understand, and begin Drupal development.
Start Your Journey
Explore our initial setup, quick guides, and more to build a solid foundation in Drupal.
Environment Setup
Learn how to set up your local development environment with DDEV and Composer. Click here for step-by-step instructions.
Git Workflow Basics
Master the Git workflow essential for DrupalXpert projects. Includes guides on branching and merging strategies.
Practical Exercises
Apply your knowledge with practical exercises that reflect real-world scenarios in Drupal development.
Development Tools
Learn about essential tools like Code Sniffer, PHPStan, and more to ensure quality code in your projects.
Starting a Project
Get a complete guide on how to begin a new project, from cloning the repository to launching the site.
Community and Support
Access our community resources, including forums, FAQs, and documentation, to help you along your learning journey.
Environment Setup
Setting up a reliable and efficient local development environment is critical for Drupal development. In this guide, we’ll walk you through each step to configure your environment with DDEV and Composer, ensuring a smooth and optimized experience.
Prerequisites
Before getting started, ensure the following tools are installed on your machine:
- DDEV: A Docker-based tool that simplifies local development and automates configurations specific to Drupal. Install DDEV
- Composer: A dependency manager for PHP, used for installing and managing Drupal libraries and modules. Install Composer
Setting Up the Environment
Once you have installed DDEV and Composer, follow these steps to set up your local development environment:
-
Clone the Project Repository
To start, clone the project’s repository to your local machine. This will pull down all the project files.
git clone https://github.com/DrupalXpert/base
cd dx-project-baseTip: Ensure you have Git installed on your machine. If not, download Git and follow the instructions.
-
Initialize the DDEV Environment
Next, start DDEV within the project directory. This command initializes the Docker environment with configurations specific to your project’s settings.
ddev start
Troubleshooting: If you encounter issues with DDEV, ensure Docker is running and try running
ddev restart
to reinitialize the environment. -
Install Dependencies with Composer
Once DDEV is running, use Composer to install all required dependencies for Drupal, including modules and libraries. This step is essential for setting up your project’s codebase correctly.
ddev composer install
Note: Composer manages dependencies defined in the
composer.json
file, making it easier to keep your libraries up to date. -
Install Drupal
Now, use Drush (the Drupal shell tool) to install Drupal. This command will set up Drupal with a basic configuration and create an admin user.
ddev drush site:install --account-name=admin --account-pass=admin -y
Configuration Tip: Use a strong password for production environments. For local development, you can keep it simple but change it in production for security.
-
Launch the Drupal Site
Once Drupal is installed, use DDEV to launch your site in the browser. This will open a local URL (usually
https://dx-project-base.ddev.site
) where you can see your Drupal site in action.ddev launch
Note: DDEV generates a secure local URL with HTTPS, which is helpful for testing site functionalities that require HTTPS.
Initial Configuration Steps
After launching your site, consider making the following initial configurations:
-
Enable Development Modules: Modules like
devel
andstage_file_proxy
can streamline development. Use the following commands to enable them:ddev drush en devel stage_file_proxy -y
-
Configure Error Reporting: To see detailed error messages, set error reporting to show all messages in
admin/config/development/logging
on your Drupal site. -
Enable Caching for Development: In development, disable render caching for real-time feedback on changes. You can configure this in
settings.local.php
.
Troubleshooting Common Issues
If you encounter issues during setup, here are some common problems and solutions:
-
DDEV Startup Errors: Ensure Docker is running and that you have allocated enough memory. Restart Docker and try
ddev restart
. -
Composer Memory Limit Errors: If Composer encounters a memory limit error, try increasing memory allocation or running:
COMPOSER_MEMORY_LIMIT=-1 ddev composer install
-
Drupal Installation Issues: Clear DDEV caches with
ddev drush cr
or restart DDEV if installation fails.
Git Workflow Basics
Our Git workflow follows these branch types:
- main: Stable production branch.
- develop: Active development branch.
- feature/: Branches for new features.
- release/: Branches for preparing production releases.
- hotfix/: Branches for urgent production fixes.
Workflow Steps
1. Feature Development
-
Create a new feature branch from
develop
:git checkout develop
git checkout -b feature/feature-name - Work on your feature, commit changes as needed.
-
Merge back into
develop
when the feature is complete:git pull origin develop
git push - Create a Merge/Pull Request with the feature.
Practical Exercises
Hands-on exercises to reinforce key Drupal concepts and workflows. You'll work through tasks like:
- Creating content types and fields
- Developing custom modules and themes
- Managing user roles and permissions
- Implementing configuration management
Development Tools
Our toolkit includes:
-
Code Formatter:
ddev phpcbf
-
Code Sniffer:
ddev phpcs
-
PHPStan for static analysis:
ddev phpstan
-
Twig Code Sniffer:
ddev twigcs
-
Configuration Export:
ddev cex
-
Configuration Import:
ddev cim
-
Cache Rebuild:
ddev cr
Starting a Project
Follow these steps to get started with a new DrupalXpert project:
- Clone the project repository.
- Set up your DDEV environment and dependencies.
- Familiarize yourself with the project's README and guidelines.
- Use our Git workflow for feature development, bug fixes, and releases.
Community and Support
Join our DrupalXpert community for ongoing support, FAQs, and peer discussions: