Skip to content

Optimize Service Provider Bindings to Prevent Circular Dependencies#1157

Merged
curtisdelicata merged 1 commit intomainfrom
sweep/Optimize-Service-Provider-Bindings-to-Prevent-Circular-Dependencies
May 10, 2025
Merged

Optimize Service Provider Bindings to Prevent Circular Dependencies#1157
curtisdelicata merged 1 commit intomainfrom
sweep/Optimize-Service-Provider-Bindings-to-Prevent-Circular-Dependencies

Conversation

@sweep-ai-deprecated
Copy link
Copy Markdown
Contributor

This pull request was created by Sweep to resolve the following request by @curtisdelicata:

@php artisan package:discover --ansi

In Container.php line 1515:

Maximum call stack size of 16728064 bytes (zend.max_allowed_stack_size - ze
nd.reserved_stack_size) reached. Infinite recursion?

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Error: Process completed with exit code 1.

Continue chatting at https://app.sweep.dev/c/f6d1a08d-13fa-442a-b234-b3b5de400b85.

Purpose

This pull request enhances the dependency injection system in the TeamServiceProvider by implementing lazy loading through callbacks to prevent circular dependencies and improve application bootstrapping.

Description

The changes modify how service bindings are registered in the TeamServiceProvider class. Instead of direct class bindings, the implementation now uses callback functions to create instances of various models and utilities. This approach:

  1. Prevents circular dependencies by deferring object instantiation until needed
  2. Improves memory usage during application bootstrap
  3. Maintains better separation of concerns
  4. Makes the dependency injection system more robust and flexible

The modification affects multiple model bindings including Family, Person, Events, and related models used in the genealogy system.

Summary

  • Modified TeamServiceProvider.php to implement lazy loading through callbacks
  • Updated bindings for the following classes:
    • BatchData
    • Family and related models (FamilyEvent, FamilySlgs)
    • Person and related models (PersonAsso, PersonAlia, PersonEvent)
    • Support models (Addr, Chan, Subm)
  • Each binding now uses a callback function that returns a new instance instead of direct class binding
  • Improved application performance by preventing eager loading of dependencies

@curtisdelicata curtisdelicata merged commit 006a78a into main May 10, 2025
1 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant