The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

Php Structure Discoverer

spatie/php-structure-discoverer image

Php Structure Discoverer stats

Downloads
82.7K
Stars
79
Open Issues
1
Forks
2

View on GitHub →

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.

spatie photo

We create open source, digital products and courses for the developer community

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Spatie Php Structure Discoverer Related Articles

Learn how to upload files in Laravel like a Pro image

Learn how to upload files in Laravel like a Pro

Read article
From idea, to blog, to live without leaving your IDE image

From idea, to blog, to live without leaving your IDE

Read article
Building your own Laravel Packages image

Building your own Laravel Packages

Read article
Create Select Options from Enums, Laravel Models, and more image

Create Select Options from Enums, Laravel Models, and more

Read article
Laravel Jetstream: Add CRUD with Spatie Permission image

Laravel Jetstream: Add CRUD with Spatie Permission

Read article
Laravel Package Training (sponsor) image

Laravel Package Training (sponsor)

Read article
LoadForge logo

LoadForge

Scalable load testing for web apps & APIs. Simulate real-world traffic and identify breaking points and performance limits with powerful, scalable load tests designed for Laravel.

LoadForge
Blastup logo

Blastup

Blastup provides social media enhancement services including buying Instagram likes, followers, and views, with features like instant delivery and a variety of packages to suit different needs.

Blastup
DreamzTech logo

DreamzTech

Hire 6-10+ Yrs. experienced skilled Laravel Developers from DreamzTech. We ensure NDA protected, 100% quality delivery. Contact Us & Discuss Your Need.

DreamzTech
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm