Skip to content

💡 Let a plugin override the make:* stubs, like Laravel's stub:publish #133

Closed

Description

@gfazioli

What

Every make:* command fills a stub from the framework, and only from there: prepareStub() calls getStubContent(), which reads vendor/wpbones/wpbones/src/Console/stubs/{name}.stub (src/Console/bin/bones 3521 and 1536–1539 at v3.0.0). A team that wants its generated controllers, providers or migrations to follow its own conventions can only edit vendor/, and the next composer update puts the framework's stubs back.

Asked on Product Hunt by a reader thinking of teams with their own scaffolding workflow: https://www.producthunt.com/p/wp-bones/what-s-new-since-august-2024

What there is today

  • Generators never overwrite an existing file; --force goes on each call (since 2.0.10).
  • A custom command (php bones make:console) can generate anything from the team's own templates, and php bones lists it under Extensions. The built-in make:* commands keep the framework's stubs.

Proposal, after Laravel's stub:publish

  • getStubContent() looks for stubs/{name}.stub in the plugin's root first and falls back to the framework's. Every make:* command goes through prepareStub(), so one change covers all of them.
  • php bones stub:publish [name ...] copies the framework's stubs into stubs/, without overwriting unless --force, like the generators.
  • deploy leaves stubs/ out of the build, as its skip list already does for the framework's own stubs folder (bones 2564).

To settle first

  • Once a stub can be overridden, its placeholders ({Namespace}, {ClassName}, {Path}, ...) are a public contract: they need documenting per stub, and a rename becomes a breaking change.
  • A published stub stops following the framework's: say so in the docs, and maybe have php bones warn when a published stub is older than the framework's copy.

Activity

  1. gfazioli commented on Oct 7, 2026

    @gfazioli
    CollaboratorAuthor

    Shipped in v3.1.0 (#134): every make:* command reads stubs/{name}.stub from the plugin first, php bones stub:publish [<stub> ...] [--force] copies the framework's stubs there, and deploy leaves them out. The placeholders of each stub are listed in the docs: https://wpbones.com/docs/bones-console/bones-console#customizing-the-stubs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions