Adam DaleyandClaude Sonnet 4.6 17b121ca51 fix(Servicedomain): require_once registrar adapter file before class_exists check (#3832)
* fix(Servicedomain): require_once registrar adapter file before class_exists check

Third-party registrar adapters uploaded after installation are absent from
Composer's static class map (generated with --optimize-autoloader), causing
class_exists() to return false even when the file is present on disk.

Mirror the pattern used by Payment adapters in ServicePayGateway: require_once
the adapter file when the class is not yet loaded, then re-check class_exists
to keep a clear error for adapters that define no class.

Fixes #3828

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017mCNdqXfyuD2n1bjFK5zsv

* fix: require_once adapter/manager files before class_exists checks

Payment adapters, server managers, and the server_manager DI factory all
relied on Composer's classmap for dynamic class resolution. With
--optimize-autoloader the classmap is static, so third-party files dropped
into src/library/ after installation are invisible to class_exists().

AntLoader (removed in #3776) previously discovered these files on the fly;
this commit restores equivalent behaviour by requiring files explicitly:

- ServicePayGateway::getAdapterClassName() now checks both nested-dir and
  flat file formats before falling back, replacing the blind `include`
- Servicehosting/Service::getServerManagerConfig() require_onces the
  manager file before calling is_callable() so the class is guaranteed
  present; Server_ has no PSR-0 entry so this also fixes non-optimised builds
- di.php server_manager factory require_oncess the manager file when the
  class is absent from the classmap (adds Path import accordingly)

Registrar adapter loading was fixed separately in the prior commit.

Related to #3828

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017mCNdqXfyuD2n1bjFK5zsv

* fix: address code-review findings on adapter/manager class loading

- Servicehosting getServerManagerConfig: wrap require_once in try/catch
  so a PHP parse error in a manager file returns [] instead of fataling
  the entire manager-list API call (restores old is_callable() behaviour)

- di.php server_manager factory: replace file_exists() with Symfony
  Filesystem::exists() per CLAUDE.md convention; extract the repeated
  ucfirst((string) $manager) call to a local $managerName variable; add
  Filesystem use-import alongside the existing Path import

- composer.json: add Server_ to the psr-0 autoload entries alongside
  Payment_ and Registrar_, giving server managers the same architectural
  treatment and making the require_once guards defensive fallbacks rather
  than the only load path

- ServicePayGateway getAdapterConfig: remove the redundant filesystem
  existence re-checks (lines 386-390) that duplicated what
  getAdapterClassName() just did; collapse into a single class_exists()
  guard with the user-facing :adapter placeholder message

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017mCNdqXfyuD2n1bjFK5zsv

* fix(tests): update ServicePayGateway tests to match refactored getAdapterConfig

After refactoring getAdapterConfig() to delegate filesystem lookups to
getAdapterClassName(), the tests were failing because:
- Three tests had atLeast()->once() expectations on filesystem->exists()
  that the method no longer calls directly
- One test expected an error message with the full class name, but the
  refactored code uses $pg->gateway (the gateway code) in the message

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017mCNdqXfyuD2n1bjFK5zsv

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-06-24 00:16:11 +02:00


FOSSBilling logo

Download button

CI Download Latest License CodeFactor Financial Contributors Crowdin Discord Stand With Ukraine Contributor Covenant

Note

FOSSBilling is under active development and currently considered beta. Expect rough edges and limited support.

FOSSBilling is a free, open-source billing and client management system. It helps online service businesses automate invoicing, payments, and client communication. While it’s popular with web hosting providers, it also works well for software licensing, digital downloads, and subscription services.

Features

  • Billing & Invoicing: automated invoices, reminders, and basic reporting.
  • Client Management: a central place for client data and communication.
  • Extensibility: extension-friendly architecture for integrations and custom features.
  • Payments: support for multiple gateways.
  • Translations: community-powered, multi-language interface.
  • Responsive UI: usable on desktop and mobile.
  • Security-focused: built with security best practices in mind.

Getting Started

Requirements

FOSSBilling runs on standard LAMP/LEMP stacks. For the latest system requirements (PHP version, extensions, database, etc.), see the official requirements.

Installation

Follow the step-by-step Getting Started guide.

Just exploring? Try the public demo.

Contributing

We welcome contributions from the community! We’re actively modernizing the codebase and there’s plenty to do.

If you prefer to start a conversation first, drop by the forum or say hello on Discord.

Star History

Star History Chart

Not a developer? Starring the repository helps others discover the project.

License

FOSSBilling is released under the Apache 2.0 license. See LICENSE for details.

This project includes third-party work:

Languages
PHP 81.7%
Twig 16.4%
TypeScript 1.6%
SCSS 0.1%