CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 6.0 API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 6.0
      • 6.0
      • 5.4
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • AttributeResolver
      • ValueObject
    • Cache
    • Collection
    • Command
    • Console
    • Container
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Lock
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Class Scanner

Scan configured application and plugin paths for PHP attributes.

Namespace: Cake\AttributeResolver

Constants

  • MAX_FILE_SIZE ¶
    10 * 1024 * 1024

    Maximum file size in bytes (10MB).

Method Summary

  • __construct() public

    Configure attribute parsing and source paths.

  • buildFinder() protected

    Build file iterators, narrowing source-only scans while retaining root-relative globs.

  • getLoadedPlugins() protected

    Get loaded plugins that should be scanned.

    Returns a consistent list of all loaded plugins regardless of execution context (CLI vs web). This ensures attribute discovery is atomic and cache is consistent.

    Excludes only:

    • Unknown plugins (configured but not installed)
    • Debug-only plugins when debug mode is disabled

    Includes CLI-only plugins even in web context to maintain cache consistency. Also includes plugins loaded dynamically via the Plugin class that may not be in the static configuration.

  • getScannedFiles() public

    Get the list of files that were scanned.

  • resolveBasePaths() protected

    Resolve canonical base paths, merging aliases while preserving plugin information.

  • scanAll() public

    Scan all configured paths and yield discovered attributes.

    Expands relative paths against APP root and all loaded plugin paths.

Method Detail

__construct() ¶ public

__construct(Cake\AttributeResolver\Parser $parser, array<string> $paths = [], array<string> $excludePaths = [], string|null $basePath = null)

Configure attribute parsing and source paths.

Parameters
Cake\AttributeResolver\Parser $parser

Attribute parser

array<string> $paths optional

Relative glob patterns to scan (e.g., ['src/*\/.php'])

array<string> $excludePaths optional

Directory names or path filters to exclude

string|null $basePath optional

Base directory path (defaults to ROOT + all plugins)

buildFinder() ¶ protected

buildFinder(): Iterator<SplFileInfo>

Build file iterators, narrowing source-only scans while retaining root-relative globs.

Returns
Iterator<SplFileInfo>

getLoadedPlugins() ¶ protected

getLoadedPlugins(): array<array{path: string, plugin: string}>

Get loaded plugins that should be scanned.

Returns a consistent list of all loaded plugins regardless of execution context (CLI vs web). This ensures attribute discovery is atomic and cache is consistent.

Excludes only:

  • Unknown plugins (configured but not installed)
  • Debug-only plugins when debug mode is disabled

Includes CLI-only plugins even in web context to maintain cache consistency. Also includes plugins loaded dynamically via the Plugin class that may not be in the static configuration.

Returns
array<array{path: string, plugin: string}>

getScannedFiles() ¶ public

getScannedFiles(): array<string>

Get the list of files that were scanned.

Returns
array<string>

resolveBasePaths() ¶ protected

resolveBasePaths(): array<array{path: string, plugin: (string|null)}>

Resolve canonical base paths, merging aliases while preserving plugin information.

Returns
array<array{path: string, plugin: (string|null)}>

scanAll() ¶ public

scanAll(): Generator<Cake\AttributeResolver\ValueObject\AttributeInfo>

Scan all configured paths and yield discovered attributes.

Expands relative paths against APP root and all loaded plugin paths.

Returns
Generator<Cake\AttributeResolver\ValueObject\AttributeInfo>
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs