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

Classy Laravel Package

ergebnis/classy

ergebnis/classy adds convenient helpers for working with PHP classes and reflection. Generate class names, namespaces, and short names, and inspect class metadata in a clean, test-friendly way—useful for tooling, libraries, and code generation.

View on GitHub
Deep Wiki
Context7

Provides collectors for classy constructs (classes, enums, interfaces, and traits).

Frequently asked questions about Classy
Can ergebnis/classy help enforce consistent class ordering (properties, methods, imports) in Laravel projects?
Yes, the package is designed to standardize class structure by enforcing ordering rules for properties, constants, methods, and imports. It’s particularly useful in Laravel for maintaining clean, predictable codebases, especially when working with large teams or CI pipelines. You can configure it to match your team’s coding standards.
How do I install ergebnis/classy in a Laravel project?
Install via Composer with `composer require ergebnis/classy`. No additional Laravel-specific setup is required beyond autoloading, as the package works with PSR-4 standards. Run `composer dump-autoload` afterward to ensure proper namespace resolution. It’s framework-agnostic but integrates seamlessly with Laravel’s autoloader.
Does ergebnis/classy support Laravel’s service container for dynamic class registration?
While the package itself doesn’t natively integrate with Laravel’s container, you can manually bind its collectors or use it to dynamically register services by scanning for interfaces or traits. For example, you could loop through collected classes and bind them to the container using `app()->bind()` or `app()->tag()`. Custom glue code may be needed for deep integration.
What Laravel versions and PHP versions does ergebnis/classy support?
The package is compatible with Laravel 9+ and PHP 8.1+. It leverages modern PHP features like enums and attributes, so ensure your Laravel project meets these requirements. Test thoroughly if using PHP 8.3+ due to potential API changes in newer PHP versions.
Can I cache the results of class scans to improve performance in Laravel?
Yes, caching is highly recommended for production use. Since reflection can be slow, store results in Laravel’s cache system (e.g., `Cache::remember()`) or Redis. For example, cache the collected classes for 15 minutes or until a config change triggers a refresh. This avoids repeated scans during web requests.
Will ergebnis/classy work with Eloquent models or Blade components?
The package focuses on general PHP class constructs and won’t directly interact with Eloquent or Blade. However, you can use it to scan and analyze model classes or custom components. For Blade-specific needs, you’d need to extend the package or combine it with Laravel’s view composers or service providers.
How do I test ergebnis/classy in a Laravel project?
Test by mocking reflection calls in unit tests or writing integration tests that verify class discovery logic. For example, create a test class hierarchy and assert the collector returns expected results. Avoid testing runtime performance in unit tests; instead, benchmark in a staging environment. Use Laravel’s `Artisan::call()` to test CLI commands if applicable.
Are there alternatives to ergebnis/classy for class analysis in Laravel?
Laravel’s built-in tools like `app()->tagged()` or `collect(app()->getBindings())` can handle basic service container queries, but they lack batch operations or formatting enforcement. For deeper analysis, consider PHPStan’s reflection extensions or custom scripts using `ReflectionClass`. However, `ergebnis/classy` offers a more ergonomic API for consistent class structuring.
Can ergebnis/classy enforce interface contracts or detect missing implementations in Laravel?
Yes, you can use the package to scan for classes implementing specific interfaces or traits, then validate their presence or enforce contracts. For example, loop through collected classes and throw exceptions if required methods are missing. This is useful for architectural enforcement, like ensuring all API controllers implement a base interface.
What are the performance implications of using ergebnis/classy in production?
Reflection operations can introduce overhead, especially in large codebases. Mitigate this by caching results and avoiding scans during web requests. For CLI tasks (e.g., CI pipelines), performance is less critical. Profile scans using Laravel’s debugging tools or Xdebug to identify bottlenecks, and restrict scans to necessary directories (e.g., `app/`) to avoid vendor/ or bootstrap/.
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