Skip to content

Add a pwa:create:config command to bootstrap the configuration file - #458

Open
Spomky wants to merge 1 commit into
1.6.xfrom
feature/create-config-command
Open

Add a pwa:create:config command to bootstrap the configuration file#458
Spomky wants to merge 1 commit into
1.6.xfrom
feature/create-config-command

Conversation

@Spomky

@Spomky Spomky commented Aug 14, 2026

Copy link
Copy Markdown
Member

Target branch: 1.6.x
Resolves issue # #84

  • It is a Bug fix
  • It is a New feature
  • Breaks BC
  • Includes Deprecations

Creating a PWA currently starts by copying config/packages/pwa.yaml from another project and tweaking the name and the description. This PR adds a pwa:create:config command that generates that file, either step by step or from options only.

Interactive mode

$ bin/console pwa:create:config

PWA Configuration Generator
===========================

 This command creates the configuration file of the bundle.
 Press Enter to accept the proposed value.

 Name of the application [Hacker News]:
 > HackerNews PWA
 Short name, displayed under the icon [HackerNews]:
 >
 Description of the application (optional):
 > A HackerNews implementation based on Symfony
 URL loaded when the application starts [/]:
 >
 Display mode [standalone]:
  [0] fullscreen
  [1] standalone
  [2] minimal-ui
  [3] browser
 >
 Theme color [#ffffff]:
 > #ff6600
 Background color [#ffffff]:
 >

 The icons and the favicons are generated from a single source image. It can be an Asset Mapper logical path (e.g. images/logo.svg) or a path to a file.

 Source image of the application (leave empty to skip):
 > images/logo.svg
 Generate the favicons from this image? (yes/no) [yes]:
 >

 Enable the service worker (offline support, caching, push notifications)? (yes/no) [yes]:
 >
 Path to the service worker source file [sw.js]:
 >

 [OK] The configuration file "config/packages/pwa.yaml" has been created.

Option mode

Every value has a dedicated option, so the command can be scripted:

bin/console pwa:create:config --no-interaction \
    --name="HackerNews PWA" \
    --description="A HackerNews implementation based on Symfony" \
    --icon=images/logo.svg

Both modes combine: interact() only asks for what was not passed as an option, and --no-interaction falls back to the defaults.

--dry-run writes the configuration on the standard output and nothing else, so it can be redirected:

bin/console pwa:create:config -n --dry-run > config/packages/pwa.yaml

Generated file

# See https://pwa.spomky-labs.com/ for the complete list of options.
pwa:
    image_processor: imagick
    manifest:
        enabled: true
        name: 'HackerNews PWA'
        short_name: HackerNews
        description: 'A HackerNews implementation based on Symfony'
        start_url: /
        display: standalone
        theme_color: '#ff6600'
        background_color: '#ffffff'
        icons:
            -
                src: images/logo.svg
                sizes: [48, 72, 96, 128, 144, 168, 192, 256, 512]
                format: png
    favicons:
        enabled: true
        default:
            src: images/logo.svg
            background_color: '#ffffff'
    serviceworker:
        enabled: true
        src: sw.js

Notes

  • The default name is derived from the project directory, and the short name is truncated to 12 characters on a word boundary.
  • The image processor is auto-detected, Imagick first as it is the only one able to read SVG sources. Requesting gd or imagick without the extension fails with an explicit message instead of writing a configuration that breaks the container.
  • When the service worker is enabled, the empty source file Asset Mapper expects is created.
  • An existing file is never overwritten without --force (or a confirmation in interactive mode).
  • One of the tests feeds the generated file back into the bundle's Processor to guarantee it is actually loadable.

The documentation lives in another repository. installation.md still says a configuration file has to be written by hand — happy to open a companion PR there.

Options

Option Description
--name The name of the application
--short-name The short name of the application, displayed under the icon
--description The description of the application
--start-url The URL loaded when the application starts
--display The display mode (fullscreen, standalone, minimal-ui, browser)
--theme-color The theme color of the application
--background-color The background color of the application
--icon The source image used to generate the icons and the favicons
--favicons / --no-favicons Whether the favicons are generated
--serviceworker / --no-serviceworker Whether the service worker is enabled
--serviceworker-src The path to the service worker source file
--image-processor The image processor used to generate the icons (imagick, gd, none)
--path The configuration file to write
-f, --force Overwrite the configuration file if it already exists
--dry-run Display the configuration instead of writing it

@Spomky Spomky self-assigned this Aug 14, 2026
@Spomky Spomky added the enhancement New feature or request label Aug 14, 2026
@Spomky Spomky added this to the 1.6.0 milestone Aug 14, 2026
@Spomky Spomky linked an issue Aug 14, 2026 that may be closed by this pull request
@Spomky
Spomky force-pushed the feature/create-config-command branch 4 times, most recently from 5152d16 to fb8ecc1 Compare August 16, 2026 20:53
Creating a PWA required copying config/packages/pwa.yaml from another
project and tweaking it by hand. The new command generates it, either
step by step or from options only.

Every value has a dedicated option, so the command can be scripted with
--no-interaction, and --dry-run prints the configuration on the standard
output instead of writing it.

The image processor is auto-detected, the favicons are wired on the
source image and, when the service worker is enabled, the empty source
file Asset Mapper expects is created.

Closes #84
@Spomky
Spomky force-pushed the feature/create-config-command branch from fb8ecc1 to dff76e0 Compare August 17, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add pwa:create:config command

1 participant