Skip to content

Service Locator Enhancement #860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: 5.x
Choose a base branch
from
Open

Conversation

mgerzabek
Copy link
Contributor

Add Support for Modular OData Service Endpoints

This PR introduces a powerful mechanism for defining modular, multi-endpoint OData services in Laravel when using flat3/lodata. It enables a clean and scalable way to expose different domains or bounded contexts under separate OData endpoints, each with their own $metadata and query surface.


Key Features

  • Multiple service endpoints via configuration (config/lodata.php)
  • Each endpoint has:
    • Its own URI segment (/odata/{key}/...)
    • Its own namespace in $metadata
    • A discover() method for dynamic schema registration
    • Optional pre-generated metadata via cachedMetadataXMLPath()
  • Built-in performance optimization:
    • discover() is only invoked on-demand
    • No overhead for regular Laravel routes

Implementation Overview

  • Introduced ServiceEndpointInterface
  • Added dynamic endpoint registration logic to ServiceProvider
  • Endpoint resolution via URI prefix (based on config('lodata.endpoints'))
  • Schema discovery per endpoint
  • Optional static metadata XML serving ($endpoint->cachedMetadataXMLPath()) to support arbitrary annotations

Documentation

For a detailed overview of the architecture, configuration, and usage of modular service endpoints, please refer to the comprehensive documentation accompanying this pull request.

Benefits

  • Clean separation of API domains (e.g., HR, Finance, Projects)
  • Flexible architecture: mix static and dynamic metadata
  • Optimized performance (no eager booting of OData models)
  • No need for extra route definitions
  • Easy to scale and maintain

Notes

This PR does not introduce breaking changes. Existing single-endpoint behavior remains the default. If config('lodata.endpoints') is empty, the global service continues to be served as before.


Let me know if you'd like this split into smaller commits or if you'd prefer to review feature-by-feature. Thanks for the great base package! 🙌

@27pchrisl
Copy link
Contributor

@mgerzabek could you rebase on 5.x, I fixed the issue with the tests.
Also, please revert the .gitignore that removes the .idea folder - that folder is supposed to be there (https://www.jetbrains.com/help/phpstorm/creating-and-managing-projects.html)

Thanks!

@mgerzabek
Copy link
Contributor Author

@27pchrisl, I've rebased on 5.x and removed the .idea from .gitignore. Is there anything else that I could do?
Please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants