Php Structure Discoverer
Php Structure Discoverer stats
- Downloads
- 82.7K
- Stars
- 79
- Open Issues
- 1
- Forks
- 2
Automatically discover structures within your PHP application
Spatie PHP Structure Discoverer Package
The Spatie PHP Structure Discoverer package is a powerful tool designed to facilitate the discovery and organization of various structures within your PHP application, such as classes, interfaces, enums, and traits. Ideal for large-scale PHP projects, this package helps streamline the process of identifying and categorizing code elements based on specific attributes or implementations.
Key Features
- Discover Various Structures: Easily find classes, interfaces, enums, and traits within your PHP application.
- Flexible Search Criteria: Filter your searches by implementation details, extensions, attributes, and custom conditions.
- Caching Mechanism: Built-in caching functionality ensures fast retrieval in production environments.
- Configurable: Comes with a customizable configuration file when used with Laravel, allowing you to specify directories, ignored files, and cache settings.
- Sorting and Conditions: Offers functionalities to sort discovered items and combine multiple conditions for precise discovery.
- Parallel Processing: Supports parallel processing to expedite the scanning of large codebases.
- Extensive Metadata: Each discovered item includes metadata for deeper insights and further processing.
Installation
Install the package via Composer:
composer require spatie/php-structure-discoverer
For Laravel users, publish the configuration file:
php artisan vendor:publish --tag="php-structure-discoverer-config"
Usage
Start by specifying the directory to search:
use Spatie\StructureDiscoverer\Discover; // Basic usage$classes = Discover::in(__DIR__)->classes()->get(); // Advanced usage with conditions$classes = Discover::in(__DIR__)->classes()->implementing(Arrayable::class)->get();
You can also define custom filters, sort results, and utilize the package's caching capabilities to enhance performance.
Advanced Features
- Chaining: Automatically resolves inheritance chains to include all relevant structures.
- Full Information Retrieval: Access complete metadata about discovered structures, not just their names.
- Customizable Caching: Choose from multiple caching strategies or define your own to optimize performance.
Caching and Performance
To leverage caching, define a structure scout class to specify what and where to discover, along with the cache driver. This can significantly speed up operations by avoiding repeated structure discovery:
EnumsStructureScout::create()->get();
Contributing
Contributions are welcome! Please refer to the package's contribution guidelines for more details.
Conclusion
The Spatie PHP Structure Discoverer package is an essential tool for developers working on complex PHP projects, providing a robust framework for managing and querying application structures efficiently. With its extensive customization options and powerful search and caching features, it helps maintain clean and manageable codebases.
For additional details on changes, security, and licensing, please consult the package's changelog, security policy, and license documentation.