Search by

drupal / drupack

Drupal-Infrastructure

Installs drupack, which serves a Drupal project with its own PHP and web server, into the project root.

Package info

git.drupalcode.org/project/drupack.git

Homepage

Type:composer-plugin

pkg:composer/drupal/drupack

Statistics

Installs: 209

Dependents: 0

Suggesters: 0


README

Drupack serves a Drupal project that you already have from one executable. The executable contains PHP, FrankenPHP and Caddy. It uses the project's own settings, database and Drush.

This package installs the drupack executable into a Composer project.

Install

composer require 'drupal/drupack:^1.0@RC'
./drupack

The package is a Composer plugin. Composer prompts once to ask whether to trust it, and y adds allow-plugins.drupal/drupack to composer.json. A run without a terminal, such as a deploy, needs that entry to be committed first:

composer config allow-plugins.drupal/drupack true

The plugin runs vendor/bin/drupack-install after every composer install and composer update, with or without --no-dev. A failed download fails the Composer command. A project that runs drupack-install from its own post-install-cmd or post-update-cmd scripts removes them.

drupack-install downloads the drupack release matching the package's version into the project root, and checks its SHA-256. It adds /drupack to the project's .gitignore, and creates that file in a git project without one. On Windows the executable is drupack.exe.

Composer runs no plugin under --no-plugins, and no install or update event under --no-scripts. A project installed either way runs vendor/bin/drupack-install by hand. A dev branch of the package has no release, so drupack-install exits with an error.

Serve the project

./drupack serves the project in the working directory, or in the directory that you pass after it. It exits with an error for a folder without Drupal core. It reads the docroot from the web root of the scaffold in composer.json, web by default.

The start prints a login link for one use through the Drush of the project. It returns the prompt once the project serves requests on http://127.0.0.1:3787, and continues to serve in the background. A project without Drush serves with no link.

  • ./drupack stop stops it.
  • --foreground serves in the terminal instead.
  • --listen IP:PORT picks another address.
  • --version prints the release and the versions of FrankenPHP, PHP, Caddy and SQLite that it contains.

The settings.php file of the project sets the database, the paths of the files and the hash salt. Drupack writes nothing into the project. For a DDEV project, point settings.local.php at the database's published port on 127.0.0.1.

Drush and PHP

  • ./drupack drush COMMAND runs the Drush of the project on the bundled PHP, from any directory inside the project.
  • ./drupack dr COMMAND runs the command line of Drupal core the same way, on Drupal 11.4 and later.
  • ./drupack composer COMMAND runs the Composer that drupack contains, on the bundled PHP, in the project root.
  • ./drupack php SCRIPT [ARGUMENTS] and ./drupack php -r CODE run the bundled PHP.

drupack exits with an error for a project with a composer.lock that requires a PHP extension which the bundled PHP lacks. The message lists the extension and the packages that need it.

Linux builds

A Linux release publishes a glibc build and a musl build per processor. drupack-install installs the glibc build when the host has the glibc loader at glibc 2.28 or later, and the musl build otherwise. DRUPACK_LIBC set to glibc or musl overrides that pick:

DRUPACK_LIBC=musl vendor/bin/drupack-install

The unpacked runtime

The first start of a version unpacks PHP and Caddy into a cache directory. Later starts of that version reuse it.

  • Linux: ~/.cache/drupack/runtime
  • macOS: ~/Library/Caches/drupack/runtime
  • Windows: %LOCALAPPDATA%\drupack\runtime

DRUPACK_CACHE_DIR moves the cache. DRUPACK_CA_FILE sets a CA bundle for the HTTPS requests of PHP, such as one that contains the root certificate of a re-signing proxy.

More

The Drupack repository covers installing without Composer, verifying a download and building an executable of your own site.