Weave Code
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

License Laravel Package

ergebnis/license

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package as a dev dependency:

composer require --dev ergebnis/license

The package provides typed abstractions for licenses (e.g., MIT, None) and components like Year, Holder, Range, Url, and Header. Start by generating or managing license text in your project—typically a LICENSE file—and inserting consistent license headers into PHP source files.

First use case: Update the copyright year and header in all PHP files using php-cs-fixer. In .php-cs-fixer.php, instantiate a license (e.g., MIT::text(...)) and configure the header_comment fixer to use $license->header(). This automates license compliance without manual edits.

Implementation Patterns

  • File-based license management: Use $license->save() to write a full license text (e.g., to LICENSE.md) during CI or pre-commit hooks.
  • Header injection: Integrate $license->header() into friendsofphp/php-cs-fixer rules to automatically prepend PHPDoc-style headers in all PHP files, ensuring headers stay in sync with your license type, holder, and year range.
  • Closed-source projects: Use Type\None to define a custom header without referencing an OSI-approved license (e.g., corporate internal projects).
  • Automated year updates: Configure a GitHub Actions workflow (or cron via CI) to run php-cs-fixer annually (e.g., on Jan 1st) and auto-open a PR to bump the license year—avoids labor-intensive yearly maintenance.

Tip: Always use Range::since(Year::fromString(...), new DateTimeZone('UTC')) to avoid time zone discrepancies across environments.

Gotchas and Tips

  • Time zones matter: Always pass a DateTimeZone (preferably UTC) when constructing Range. Omitting it or using inconsistent time zones can lead to off-by-one-year bugs in edge cases.
  • Header comment format: The header_comment fixer expects a string—.header() returns exactly that—but ensure the fixer’s comment_type matches your style (e.g., 'PHPDoc', 'block', or 'doc'). Mismatched types may cause conflicts with other formatting rules.
  • No BSD3Clause type despite docs: The README lists BSD3Clause in a link, but only MIT, None exist in the current release. Verify available types via the src/Type/ directory or composer show to avoid guesswork.
  • Extension point: You can subclass Template or Header to add custom license formatting, but the package currently provides no official API for plugging in arbitrary license types (e.g., Apache-2.0). Consider contributing a PR if needed.
  • Dry-run before committing: Always run php-cs-fixer fix --diff --dry-run first to preview changes—headers can be sensitive to location (e.g., after_declare_strict must appear after declare(strict_types=1)) and overwrite existing headers, potentially breaking code.
  • CI-only automation: If running automated year updates via CI, avoid triggering new builds on PRs created by the bot—use a bot account and GitHub token with restricted permissions, as shown in the docs.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport