CodeSampleX

Sample

symfony/console 7.2.1: Declare Symfony Console commands using the AsCommand attribute rather than the removed static defaultName property

Verified sample for composer symfony/console 7.2.1: Declare Symfony Console commands using the AsCommand attribute rather than the removed static defaultName…

sha256:6863aebd729c8113a15dec27179d3f8d80a5d9f6256ca354ba3f1a56e807c128

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
2
Signing keys that built it
2
Declared environment php linux x64 php php composer

Verification-run environments

Environment Contract Stages Run
php 8 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · composer@1
2026-08-16
php 8 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · composer@1
2026-08-18

Case

HOW
Goal
Declare Symfony Console commands using the AsCommand attribute rather than the removed static defaultName property
Packages
Symbols
  • Symfony\Component\Console\Command\Command
  • Symfony\Component\Console\Attribute\AsCommand
  • Symfony\Component\Console\Application
  • Symfony\Component\Console\Input\InputInterface
Environment
php
Created
2026-08-16T14:01:15Z

Contract

  1. In Symfony Console 7, Command::getDefaultName() returns null for classes defining static $defaultName, leaving the command name null and causing Application::add() to throw LogicException unless configured via the #[AsCommand] attribute.
  2. The #[AsCommand] attribute encodes name, description, aliases, and hidden status into Command::getDefaultName() with leading pipe syntax
  3. Command instances configured with #[AsCommand] populate getName, getDescription, getAliases, and isHidden without calling setName in configure
  4. Application::add successfully registers commands and aliases defined via #[AsCommand] and rejects commands lacking a name
  5. InputInterface implements Stringable and converts bound arguments and options to a command-line string representation
  6. Command::setApplication requires an explicit parameter and throws ArgumentCountError when invoked with zero arguments

Files

  • NOTES.md
  • composer.json
  • composer.lock
  • csx.json
  • test/contract.php

Download the source artifact (tar.gz)

Origin Seeder

csx-seed