### Using Composer to Install Drupal Source: https://www.drupal.org/documentation/develop Learn how to use Composer, the dependency manager for PHP, to install Drupal and manage project dependencies. This is the recommended way to start a new Drupal project. ```Shell # Create a new Drupal project using Composer composer create-project drupal/recommended-project my-drupal-project cd my-drupal-project # Install dependencies composer install ``` -------------------------------- ### Introduction to Git for Drupal Source: https://www.drupal.org/documentation/develop An introduction to using Git, a distributed version control system, for managing Drupal projects. Covers basic concepts and setup. ```Shell # Initialize a Git repository git init # Add files to staging area git add . # Commit changes git commit -m "Initial commit" ``` -------------------------------- ### Drupal User Interface Standards - Tours Source: https://www.drupal.org/documentation/develop Guidelines for implementing user tours in Drupal to guide users through features. ```JavaScript // Example: Defining a tour step using Drupal's Tour API // Drupal.tour.register('my_tour', { // title: 'Welcome!', // description: 'This is the first step of the tour.', // element: '#my-element', // position: 'bottom' // }); ``` -------------------------------- ### Setting up Git for Drupal Projects Source: https://www.drupal.org/documentation/develop Guides on how to configure Git for Drupal development, including setting up `.gitignore` files to exclude unnecessary files and directories. ```Shell # Example .gitignore entry for Drupal # Ignore vendor directory /vendor/ # Ignore Drupal core files if not managed by Composer # core/ # Ignore temporary files and logs *.log tmp/ ``` -------------------------------- ### Install Drupal ECA 3.0.2 Source: https://www.drupal.org/documentation/project/eca Installs version 3.0.2 of the Drupal ECA module using Composer. This version is compatible with Drupal ^11.2. ```bash composer require 'drupal/eca:^3.0' ``` -------------------------------- ### Drupal Markup Style Guide Source: https://www.drupal.org/documentation/develop Standards for writing HTML markup in Drupal, ensuring consistency and adherence to best practices. ```HTML

My Drupal Site

Article Title

Article content...

``` -------------------------------- ### Install Drupal ECA 2.1.13 Source: https://www.drupal.org/documentation/project/eca Installs version 2.1.13 of the Drupal ECA module using Composer. This version supports Drupal ^10.3 or ^11. ```bash composer require 'drupal/eca:^2.1' ``` -------------------------------- ### Creating a New Drupal Project on drupal.org Source: https://www.drupal.org/documentation/develop Guidelines for creating and managing new Drupal modules, themes, or distributions hosted on drupal.org. -------------------------------- ### Benchmarking and Profiling Drupal with Apache Bench (ab) Source: https://www.drupal.org/documentation/develop Using the Apache Bench (ab) tool to benchmark the performance of a Drupal site. Helps in identifying performance bottlenecks under load. ```Shell # Benchmark a Drupal page with Apache Bench # ab -n 100 -c 10 http://your-drupal-site.com/node/1 ``` -------------------------------- ### Drupal Development Tools Overview Source: https://www.drupal.org/documentation/develop Provides an overview of commonly used tools that aid in Drupal development. This section lists essential utilities for a streamlined development workflow. -------------------------------- ### Using GitLab to Contribute to Drupal Source: https://www.drupal.org/documentation/develop Instructions on leveraging GitLab for contributing to Drupal projects, including forking repositories, creating branches, and submitting merge requests. ```Shell # Fork a Drupal project on GitLab # Clone your fork locally git clone # Add the upstream repository git remote add upstream # Create a new branch for your changes git checkout -b feature/my-new-feature ``` -------------------------------- ### Using Drupal's Composer Scaffold Source: https://www.drupal.org/documentation/develop Explains how to use Drupal's Composer scaffold plugin to manage project structure and ensure essential files are correctly placed after Composer operations. ```Shell # Composer scaffold is typically configured in composer.json # Example configuration snippet: # "extra": { # "drupal-scaffold": { # "locations": { # "web-root": "web/" # } # } # } ``` -------------------------------- ### Common Drupal Development Workflow with Git Source: https://www.drupal.org/documentation/develop Describes a typical Git workflow for Drupal development, emphasizing collaboration and efficient code management. ```Shell # Fetch changes from upstream git fetch upstream # Merge changes into your local branch git merge upstream/main # Push your changes to your fork git push origin main ``` -------------------------------- ### Drupal Coding Standards - Configuration File Naming Conventions Source: https://www.drupal.org/documentation/develop Standards for naming configuration files in Drupal projects, ensuring clarity and consistency. ```YAML # Example: Naming convention for a Drupal configuration file # system.site.yml # user.role.administrator.yml ``` -------------------------------- ### Drupal User Interface Standards - Dropbutton Source: https://www.drupal.org/documentation/develop Guidelines for using and implementing the Drupal dropbutton component. ```HTML
``` -------------------------------- ### Drupal Project Issue Tracking Overview Source: https://www.drupal.org/documentation/develop An overview of how the Drupal project utilizes an issue queue to manage bugs, feature requests, and other project-related tasks. -------------------------------- ### Drupal Coding Standards - SQL Source: https://www.drupal.org/documentation/develop Guidelines for writing SQL queries in Drupal, emphasizing the use of the Database API for portability and security. ```PHP // Using Drupal's Database API for SELECT queries // $query = Drupal::database()->select('users', 'u'); // $query->fields('u', ['uid', 'name']); // $query->condition('u.status', 1); // $result = $query->execute(); // foreach ($result as $row) { // // Process row // } ``` -------------------------------- ### Drupal User Interface Standards - Tabs Source: https://www.drupal.org/documentation/develop Guidelines for using tabs in Drupal for organizing content and actions. ```HTML ``` -------------------------------- ### Managing Drupal Project Dependencies with Composer Source: https://www.drupal.org/documentation/develop Details on how to manage dependencies for both contributed and custom Drupal projects using Composer. This includes adding, updating, and removing packages. ```Shell # Add a new dependency composer require drupal/module_name # Update dependencies composer update # Remove a dependency composer remove drupal/module_name ``` -------------------------------- ### XHProf Code Profiler for Drupal Source: https://www.drupal.org/documentation/develop XHProf is a code profiler that can be used to analyze the performance of Drupal applications. It helps identify bottlenecks and optimize code execution. ```PHP // Example usage of XHProf (conceptual) // require_once 'xhprof_lib/xhprof_lib.php'; // require_once 'xhprof_lib/utils/xhprof_runs.php'; // // $xhprof_data = xhprof_sample_disable(); // $xhprof_runs = new XHProfRuns_Default(); // $run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_foo"); // echo "http:///index.php?run=" . $run_id . "&source=xhprof_foo"; ``` -------------------------------- ### Handling User Input in Drupal for Security Source: https://www.drupal.org/documentation/develop Best practices for securely handling user input in Drupal to prevent vulnerabilities like cross-site scripting (XSS) and SQL injection. ```PHP // Sanitize user input before displaying it // echo check_plain($user_input); // Use prepared statements for database queries // $query = db_select('my_table', 't'); // $query->condition('field', $user_input, '='); // $result = $query->execute(); ``` -------------------------------- ### Drupal Coding Standards - JavaScript Source: https://www.drupal.org/documentation/develop Best practices for writing JavaScript in Drupal, including module patterns, event handling, and integration with Drupal's JavaScript API. ```JavaScript // Example: Using Drupal behaviors for JS initialization (function ($, Drupal, drupalSettings) { Drupal.behaviors.myModule = { attach: function (context, settings) { $('.my-element', context).once('my-behavior').each(function () { // Your JavaScript code here }); } }; })(jQuery, Drupal, drupalSettings); ``` -------------------------------- ### ECA Features Overview Source: https://www.drupal.org/documentation/project/eca ECA offers several key features including plugin managers for modellers, events, and conditions, integration with Drupal core actions, extensive context stack support, and support for various functionalities like caching, loops, and logging. ```PHP Plugin managers for modellers, events, and conditions Interfaces and abstract base classes and traits Integration of all actions from the Drupal core Actions module and all available contrib modules Extensive context stack support (optional with Context Stack) Support for caching, loops, logging, states, tokens, etc. Prevents recursions TypedData support Tagging for event characterization Models are stored in config, so they can be imported and exported via Drush or the configuration management UI ``` -------------------------------- ### Drush for Drupal Development Source: https://www.drupal.org/documentation/develop Drush is a command-line shell and scripting interface for Drupal. It is used for common site administration and development tasks. ```Shell drush status drush cr drush updb ``` -------------------------------- ### Drupal Coding Standards - CSS Source: https://www.drupal.org/documentation/develop Standards for writing CSS in Drupal projects, focusing on organization, naming conventions (like BEM), and maintainability. ```CSS /* Example: Using BEM naming convention for CSS classes */ .button { /* Base styles */ } .button--primary { /* Modifier styles */ } .button__icon { /* Component part styles */ } ``` -------------------------------- ### Drupal Coding Standards - PHP Source: https://www.drupal.org/documentation/develop The Drupal Coding Standards for PHP, outlining best practices for writing clean, maintainable, and consistent PHP code within the Drupal ecosystem. ```PHP // Follow PSR standards and Drupal-specific guidelines. // Example: Proper indentation and naming conventions. // class MyService { // public function myMethod($argument) { // return $argument; // } // } ``` -------------------------------- ### Drupal Coding Standards - Accessibility (A11y) Source: https://www.drupal.org/documentation/develop Guidelines for ensuring Drupal websites and custom code meet accessibility standards (WCAG). ```HTML ``` -------------------------------- ### Drupal Coding Standards - Spelling Source: https://www.drupal.org/documentation/develop Guidelines for maintaining consistent spelling in Drupal code, comments, and documentation. -------------------------------- ### Drupal User Interface Standards - Navigation Source: https://www.drupal.org/documentation/develop Standards for implementing navigation elements in Drupal, including menus and breadcrumbs. ```HTML ``` -------------------------------- ### Drupal User Interface Standards - Buttons Source: https://www.drupal.org/documentation/develop Standards for styling and implementing buttons in the Drupal user interface. ```HTML ``` -------------------------------- ### HMAC Best Practices in Drupal Source: https://www.drupal.org/documentation/develop Details on implementing Hash-based Message Authentication Code (HMAC) in Drupal for secure data integrity and authentication. ```PHP // Generate an HMAC signature // $key = Drupal::service('settings.secure_api_key')->get(); // $data = 'some data to sign'; // $signature = hash_hmac('sha256', $data, $key); // Verify an HMAC signature // $received_signature = $_GET['signature']; // if (hash_equals($signature, $received_signature)) { // // Signature is valid // } ``` -------------------------------- ### Drupal User Interface Standards - Form Elements Source: https://www.drupal.org/documentation/develop Guidelines for using standard form elements in Drupal's user interface, ensuring consistency and usability. ```HTML
``` -------------------------------- ### Xdebug Debugger for Drupal Source: https://www.drupal.org/documentation/develop Xdebug is a PHP debugger and code profiler that enhances the development experience. It allows for step-by-step code execution and variable inspection. ```PHP ; Enable Xdebug extension ;zend_extension=xdebug ; Configure Xdebug for remote debugging ;xdebug.mode=debug ;xdebug.start_with_request=yes ;xdebug.client_host=127.0.0.1 ;xdebug.client_port=9003 ``` -------------------------------- ### Profiling Drupal Memory Usage Source: https://www.drupal.org/documentation/develop Techniques and tools for profiling memory usage in Drupal applications to identify memory leaks and optimize resource consumption. ```PHP // Using memory_get_usage() and memory_get_peak_usage() // $start_memory = memory_get_usage(); // // ... your code ... // $end_memory = memory_get_usage(); // $peak_memory = memory_get_peak_usage(); // // echo "Current memory usage: " . ($end_memory / 1024) . " KB\n"; // echo "Peak memory usage: " . ($peak_memory / 1024) . " KB\n"; ``` -------------------------------- ### Drupal Coding Standards - Twig Source: https://www.drupal.org/documentation/develop Standards for writing Twig templates in Drupal, focusing on clean syntax, avoiding logic in templates, and using Drupal-specific functions. ```Twig {# Example: Rendering a variable and applying a filter #}

{{ page.title|striptags|title }}

{# Example: Looping through a list #}
    {% for item in items %}
  • {{ item }}
  • {% endfor %}
``` -------------------------------- ### Drupal Output Filtering for Security Source: https://www.drupal.org/documentation/develop Explains why Drupal filters output by default and how this mechanism helps prevent security issues. ```PHP // Drupal's theme layer automatically applies filters like check_plain() // to prevent XSS attacks when rendering data. // Example: Rendering a user-provided string in a Twig template // {{ user_comment|safe_join }}; // 'safe_join' is a placeholder for Drupal's auto-escaping ``` -------------------------------- ### ECA Core Functionality Source: https://www.drupal.org/documentation/project/eca ECA Core acts as a processor that validates and executes event-condition-action plugins. It leverages Drupal core components and provides a plugin manager for conditions, events, and actions, allowing for easy extension. ```PHP ECA Core is a processing engine that runs in the background. It needs an integrated modeller - a front-end tool with which you define event-condition-action models (a.k.a. rules). ECA provides a plugin manager with an interface to easily integrate existing tools that already provide that capability. And if the modeller supports templates for events, conditions and actions, ECA will provide them for all the plugins that are available on the current Drupal site. ``` -------------------------------- ### Drupal User Interface Standards - Table Source: https://www.drupal.org/documentation/develop Standards for displaying data in tables within the Drupal user interface. ```HTML
Header 1 Header 2
Data 1.1 Data 1.2
Data 2.1 Data 2.2
``` -------------------------------- ### PHPStan for Drupal Static Analysis Source: https://www.drupal.org/documentation/develop PHPStan is a static analysis tool for PHP. It helps find bugs in code without executing it, improving code quality and maintainability in Drupal projects. ```Shell # Install PHPStan # composer require --dev phpstan/phpstan # Run PHPStan on your Drupal project # vendor/bin/phpstan analyse src --level=5 ``` -------------------------------- ### Disabling Caching in Drupal Source: https://www.drupal.org/documentation/develop Instructions on how to disable caching in Drupal, often used during development to ensure changes are immediately reflected. ```PHP // Disable all caching // In Drupal 7: // variable_set('cache', '0'); // In Drupal 8/9/10 (via Drush): // drush php-eval "\Drupal\Core\Site\Settings::set('cache', FALSE);" // Or by clearing cache: // drush cr ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.