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.
$license->save() to write a full license text (e.g., to LICENSE.md) during CI or pre-commit hooks.$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.Type\None to define a custom header without referencing an OSI-approved license (e.g., corporate internal projects).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.
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 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.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.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.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.How can I help you explore Laravel packages today?