sergeant/drupal-project

SGT Project template for Drupal 10 projects with Composer

Installs: 508

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 1

Forks: 942

Type:project

7.1.0 2024-01-05 17:58 UTC

README

This is the fork of Composer template for Drupal projects. All documentation regarding this project is available on given url. The notes bellow are addition/override of the source documentation. The updates from forked project has to be implemented manually.

Lead maintainer: Zan Vidmar (contact)

Maintainer: Aljosa Furlanic (contact)

Usage

Access

For successful installation of Sergeant modules, read access to Sergeant private repositories is needed.

Sergeant workflow

Sergeant drupal project init article (private)

Installation (!)

Initialize project with command line generator

  1. command line generator

Initialize project just with composer

First you need to install composer.

  1. After that you can create the project:
composer create-project sergeant/drupal-project:dev-10.x-sgt some-directory --stability dev --no-interaction

Change the some-directory with your directory where the project will be.

In case if something is not installed correctly try to clear composer cache first (composer clear-cache), and than report an issue.

  1. Install Drupal with the Installation Profile (everything is handled by sgt_installation_profile module).

  2. Create new checklist /admin/config/sergeant/sgt_checklist and go trough all checklist items.

Settings

  • For global setting use /web/sites/*/settings.php
  • For environment settings use /web/sites/*/settings.local.php
  • For development services use /web/sites/default/local.services.yml (do not use this on production!)

Development local.services.yml example:

parameters:
    session.storage.options: { gc_probability: 1, gc_divisor: 100, gc_maxlifetime: 200000, cookie_lifetime: 2000000 }
    twig.config: { debug: true, auto_reload: true, cache: true }
    renderer.config: { required_cache_contexts: ['languages:language_interface', theme, user.permissions], auto_placeholder_conditions: { max-age: 0, contexts: [session, user], tags: {  } } }
    http.response.debug_cacheability_headers: true
    factory.keyvalue: {  }
    factory.keyvalue.expirable: {  }
    filter_protocols: [http, https, ftp, news, nntp, tel, telnet, mailto, irc, ssh, sftp, webcal, rtsp]
    cors.config: { enabled: false, allowedHeaders: {  }, allowedMethods: {  }, allowedOrigins: ['*'], exposedHeaders: false, maxAge: false, supportsCredentials: false }

Updating Drupal project itself

That will update some settings in composer.json file and also some other Drupal project related files. Updates are handled by sergeant/sgt_drupal_project_update;

To update drupal project to last version: composer update_sgt_drupal_project

or to update it to specific project version: composer update_sgt_drupal_project v3.0.5

Keep local "repositories" in composer.json file as they are

In case you would not like to update "repositories" data (for example: if you change library version for given project only) use: add keep-local-repositories-data=true flag.

Example composer update_sgt_drupal_project keep-local-repositories-data=true

Updates (!)

Every time when Drupal core is updated, we have to update Drupal module Sergeant core (sgt_installation_profile). Sergeant Installation Profile holds all currently active patches for Drupal core and modules required by Sergeant Installation Profile. All other patches has to be handled on project level.

What does this template adds to forked drupal-composer/drupal-project

Packages required by default (wiht its dependency tree)

All modules listed below in dependency tree are required by default. sergeant/sgt_installation_profille module handles all other required contributed Drupal modules.

Sergeant Drupal project (composer project)

  • sgt_core (module)
    • sgt_checklist
      • entity_creator_api
    • sgt_handbook
    • sgt_paragraphs
      • sgt_field_paragraph_settings
  • sgt_ignite (theme)
    • sgt_ignite_components
    • sgt_ignite_features
  • sgt_installation_profille (profile)
    • all required Drupal modules

Included repositories

This only include package sources, the installation is optional and always made by developer.

  • sergeant/sgt_devel
  • sergeant/sgt_filter_query_api
  • sergeant/sgt_media_colorbox_field_formatter
  • sergeant/sgt_media_crop
  • sergeant/sgt_tiles

Included Sergeant private repositories:

  • sergeant/entity_creator_api (repo)
  • sergeant/sgt_checklist (repo)
  • sergeant/sgt_core (repo)
  • sergeant/devel (repo)
  • sergeant/sgt_drupal_project_update (repo)
  • sergeant/sgt_field_paragraph_settings (repo)
  • sergeant/sgt_filter_query_api (repo)
  • sergeant/sgt_handbook (repo)
  • sergeant/sgt_ignite (repo)
  • sergeant/sgt_ignite_components (repo)
  • sergeant/sgt_ignite_features (repo)
  • sergeant/sgt_installation_profile (repo)
  • sergeant/sgt_media_colorbox_field_formatter (repo)
  • sergeant/sgt_media_crop (repo)
  • sergeant/sgt_paragraphs (repo)
  • sergeant/sgt_tiles (repo)

Required contrib packages (JS libraries)

  • harvesthq/chosen is required via sgt_installation_profille => drupal/chosen. Drupal project composer.json file includes requrements mentioned in drupal/chosen readme file. (repo, docs)

Included contrib packages (JS libraries)

  • gfranko/jquery.tocify.js composer require gfranko/jquery.tocify.js (repo, docs)
  • jackmoore/colorbox composer require jackmoore/colorbox (repo, docs)

Composer file modifications

Installer paths

Installer paths are changed to a non standard paths, to met the Sergeant workflow with Sergeant modules and Sergeant Ignite theme.

All Sergeant modules are placed in web/modules/sgt/ directory.

"web/modules/sgt/{$name}": [
    "sergeant/sgt_checklist",
    "sergeant/sgt_core",
    "sergeant/sgt_devel",
    "sergeant/sgt_field_paragraph_settings",
    "sergeant/sgt_filter_query_api",
    "sergeant/sgt_handbook",
    "sergeant/sgt_ignite_components",
    "sergeant/sgt_ignite_features",
    "sergeant/sgt_media_colorbox_field_formatter",
    "sergeant/sgt_media_crop",
    "sergeant/sgt_paragraphs",
    "sergeant/sgt_tiles"
],

The structure of module folder:

  • contrib web/modules/contrib/ (for Drupal contrib modules, git ignored, managed by composer)
  • custom web/modules/custom/ (for Drupal custom modules per project, git managed)
  • sgt web/modules/sgt/ (for Sergeant Drupal contrib modules, git ignored, managed by composer)

Sergeant Ignite theme is placed in web/themes/sgt_ignite/ directory.

"web/themes/sgt_ignite/ignite_core": [
    "sergeant/sgt_ignite"
],

Sergeant installation profile is placed in in web/profiles/sgt/ directory.

"web/profiles/sgt/{$name}": [
    "sergeant/sgt_installation_profile"
]

Other modifications

  • Custom folders ("private", "tmp") are added into $dir array in scripts/composer/ScriptHandler.php file.
  • to accept patches from dependencies "enable-patching": true was added to extra section (source: composer-patches)
  • Create the files directory with chmod 0775 instead of 0777
  • ScriptHandler (with related json autoload => classmap) has additional function that copy all configuration files from Drupal standard profile to Sergeant Installation Profile.

PHP version

This template by default requires at least PHP 8.1

DDEV setup

Troubleshooting

In case of denied acces to private repos add keys to ddev container by ddev auth ssh command