Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Api Client Bundle Laravel Package

chaplean/api-client-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

To quickly enable logging for specific APIs, start by configuring the enable_database_logging and enable_email_logging options in your package's configuration file. The new getName() method in AbstractApi (defaulting to snake_case class name) provides a standardized way to reference APIs.

First use case:

// config/api-logger.php
'logging' => [
    'enable_database_logging' => ['foo_api', '!bar_api'], // Enable DB logging for foo_api, disable for bar_api
    'enable_email_logging' => '~', // Enable email logging for all APIs
],

Implementation Patterns

Granular Logging Control

Use the new array syntax to selectively enable/disable logging per API:

// Enable logging for all APIs except 'payment_api'
'logging' => [
    'enable_database_logging' => ['!payment_api'],
],

Dynamic API Identification

Extend AbstractApi to customize getName() for better readability:

class PaymentApi extends AbstractApi {
    public function getName(): string {
        return 'payment_service'; // Custom name instead of snake_case
    }
}

Migration Strategy

Replace deprecated true values with ~ in config files:

- 'enable_database_logging' => true
+ 'enable_database_logging' => '~'

Logging Integration

Use the new logging capabilities with existing services:

// In a service class
public function __construct(private ApiLogger $logger) {
    $this->logger->log('payment_processed', ['amount' => 100]);
}

Gotchas and Tips

Deprecation Warning

The true value for logging options is now deprecated. Update your config files to use ~ for "enable all" behavior.

Array Syntax Quirks

  • ['!api_name'] disables logging only for that API (others remain unchanged)
  • Omitting the key disables logging for all APIs
  • Mixing inclusion/exclusion (e.g., ['api1', '!api2']) requires careful planning

Debugging Tips

For troubleshooting:

// Check which APIs are enabled for logging
$enabledApis = config('api-logger.enable_database_logging');
$api = new FooApi();
$api->getName(); // Verify naming matches config

Extension Points

Customize logging behavior by:

  1. Extending AbstractApi to modify getName()
  2. Publishing config with php artisan vendor:publish --tag=api-logger-config
  3. Creating custom logging channels by implementing ApiLoggerInterface

Performance Note

The new array-based system adds minimal overhead (~1ms per request for name resolution), but test in production-like environments for your specific API count.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware