Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Code Generator Utils Laravel Package

ocramius/code-generator-utils

A small toolkit of utilities that simplifies programmatic PHP code generation. It offers helpers for building class and method definitions, sanitizing identifiers, and producing unique names—handy when writing proxy generators, scaffolding tools, or anything that emits PHP source at runtime.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Build vs. buy on runtime code generation. The package is a thin set of adapters — Inflector (class/trait/interface name rewriting), GeneratorStrategy (EvaluatingGeneratorStrategy for eval-based generation, SavingGeneratorStrategy for writing to disk), FileLocator and Autoloader helpers — that make nikic/php-parser and Reflection cooperate. That is exactly the layer you would otherwise spec from scratch when a feature needs generated PHP classes. Using it as a reference design shortens the estimate for "do we build our own proxy/scaffolding layer?" from weeks to days.
  • Dependency risk assessment for existing code. The package is a known transitive building block in proxy/lazy-loading stacks (e.g. ocramius/proxy-manager and its LTS fork). If any roadmap item depends on runtime proxy generation, this is on your critical path — and it is archived, which is a roadmap input, not a footnote.
  • Architecture choice: eval-and-go vs. write-to-disk. The pluggable strategy interface is the decision variable for cold-start latency vs. opcache/preloading friendliness. That trade-off shows up in performance budgets and deployment topology (read-only containers rule out disk generation).
  • Use cases worth scoping: lazy-loading proxies, virtual proxies for heavy services, DI container compilation, generated DTOs/hydrators, internal scaffolding and one-off migration scripts.
  • Interop investment. It defines the seam between reflection metadata and AST output. If your platform already standardizes on laminas-code or php-parser, this tells you how cheaply the two can be bridged.
  • Ecosystem positioning. Low stars (98), zero dependents, and an archived repo mean it is a pattern to learn from, not a component to standardize on. That is a "do not put this in the platform contract" decision, made early and cheaply.

When to Consider This Package

Adopt (or, realistically, borrow) it when:

  • You are writing a library — not an application — that generates PHP classes at runtime or build time.
  • You need swappable generation strategies (eval for dev, disk for prod/preload) without rewriting your generator.
  • You need class-name inflection (aliasing, interface/trait renaming) so generated symbols don't collide or leak implementation names.
  • You are already inside the Ocramius / Laminas / Doctrine orbit and want idioms that match that stack.
  • You have a frozen, well-understood scope where an archived dependency is acceptable — ideally vendored or forked, with the fork recorded as your own code.

Look elsewhere when:

  • Archived status is disqualifying — which it is for most production roadmaps. No security backports, no PHP-version guarantees, no upstream to escalate to.
  • You need an actively maintained generator: laminas/laminas-code, nette/php-generator, or nikic/php-parser directly.
  • You are an application team. Runtime codegen is rarely the right call for app code; build-time generation (Rector, PHP-Parser printers) is safer and easier to review.
  • You need template-driven generation with a broad feature surface; this is a utilities layer, not a framework.
  • You rely on community support, docs, or examples — 0 dependents means no battle-testing signal to lean on.
  • Your platform is on newer PHP minors where an unmaintained parser adapter may drift.

How to Pitch It (Stakeholders)

To executives: A small, MIT-licensed PHP utility library that sits underneath runtime code generation — the machinery behind proxies and generated classes. It is ~100 stars, zero downstream dependents, and archived, so my recommendation is not to adopt it as a dependency. Its value is as a free reference design: it de-risks one of our build-vs-buy questions and lets us avoid inventing an internal codegen layer. Cost of the decision: near zero. Risk if we mistakenly standardize on it: an unmaintained component in the platform contract.

To engineering: It is the glue between php-parser and Reflection — inflection, generator strategies, file location, autoloading. If we need generated classes, this is the shortest path to a working prototype: eval-based for dev, disk-based for opcache/preload. Treat it as a spec, not a dependency: if we actually ship codegen, vendor the pieces we need or go straight to laminas-code / php-parser, which are maintained. Flag any existing transitive usage for a fork-and-own plan.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core