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

Auth Common Bundle Laravel Package

da/auth-common-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

First Steps

  1. Installation Add the bundle via Composer (preferably pinned to a stable version if available, though dev-master is the only option here):

    composer require da/auth-common-bundle:dev-master
    

    Register it in AppKernel.php:

    $bundles[] = new Da\AuthCommonBundle\DaAuthCommonBundle();
    
  2. Initial Exploration

    • Check the bundle’s Resources/config/services.yml for core services (e.g., authentication utilities, OAuth helpers).
    • Review DaAuthCommonBundle/DependencyInjection/ for configuration knobs (if any).
    • Look for Twig extensions or EventSubscribers in Resources/config/ for integration hooks.
  3. First Use Case If the bundle is meant to support DaOAuth* or DaApi* bundles, test its core functionality by:

    • Extending a base Authenticator class (if provided) for OAuth flows.
    • Using shared services like DaAuthCommonBundle\Service\TokenManager (hypothetical) for JWT/OAuth token handling.

Implementation Patterns

Core Workflows

  1. Service Integration

    • The bundle likely provides shared services (e.g., DaAuthCommonBundle\Service\AuthService). Inject these into controllers/services:
      use Da\AuthCommonBundle\Service\AuthService;
      
      class MyController extends Controller {
          public function __construct(AuthService $authService) {
              $this->authService = $authService;
          }
      }
      
    • Override or extend services via config.yml or compiler passes.
  2. Event Listeners/Subscribers

    • Hook into Symfony events (e.g., security.interactive_login) using the bundle’s subscribers:
      # app/config/config.yml
      da_auth_common:
          listeners:
              my_custom_listener: true
      
  3. Twig Extensions

    • Use provided Twig filters/functions (e.g., da_auth_check_permission) in templates:
      {% if 'admin' in app.user.roles|da_auth_check_permission %}
          {# Show admin panel #}
      {% endif %}
      
  4. Configuration-Driven Behavior

    • Customize via config.yml (if documented). Example:
      da_auth_common:
          oauth:
              client_id: your_client_id
              client_secret: your_secret
      

Integration Tips

  • Pair with DaOAuth* Bundles: If this is a dependency, ensure the OAuth bundle is installed and configured first.
  • API Authentication: Use shared token services to validate API requests (e.g., middleware for DaApi* bundles).
  • Legacy Code: If migrating from Symfony2, check for deprecated methods (e.g., ContainerAware services).

Gotchas and Tips

Pitfalls

  1. Outdated Codebase

    • Last release: 2014. Assume:
      • No PHP 8+ support.
      • Symfony 2.x only (test compatibility with your version).
      • No modern dependency management (e.g., autowiring may not work).
    • Workaround: Fork and update dependencies manually.
  2. Lack of Documentation

    • No clear API docs or usage examples. Reverse-engineer:
      • Check DaAuthCommonBundle/Tests/ for usage patterns.
      • Inspect DaAuthCommonBundle/Resources/config/services.yml for service names.
  3. Hardcoded Dependencies

    • The bundle may assume DaOAuth* or DaApi* bundles are installed. Test in isolation if possible.
  4. Configuration Quirks

    • No da_auth_common section in the README’s config.yml example. Guess based on:
      da_auth_common:
          # Hypothetical options
          token_ttl: 3600
          debug: "%kernel.debug%"
      

Debugging Tips

  • Enable Debug Mode: Symfony’s profiler may reveal missing services or misconfigurations.
  • Check Compiler Passes: If services fail to load, inspect DaAuthCommonBundle/DependencyInjection/Compiler/ for required passes.
  • Log Service Dumps: Dump loaded services to verify registration:
    $this->get('debug.container')->getServiceIds();
    

Extension Points

  1. Custom Services

    • Override services via config.yml:
      services:
          da_auth_common.auth_service:
              class: AppBundle\Service\CustomAuthService
              arguments: ['@da_auth_common.default_service']
      
  2. Event Listeners

    • Create a custom subscriber to extend auth logic:
      class MyAuthSubscriber implements EventSubscriberInterface {
          public static function getSubscribedEvents() {
              return ['security.interactive_login' => 'onLogin'];
          }
      }
      
  3. Twig Extensions

    • Add custom filters by extending the bundle’s DaAuthCommonBundle\Twig\Extension\AuthExtension.

Pro Tips

  • Static Analysis: Use phpstan or psalm to catch type mismatches (if the bundle lacks type hints).
  • Isolation Testing: Test the bundle in a fresh Symfony 2.x project to avoid conflicts.
  • Fallbacks: If a service fails, implement a decorator pattern to wrap the bundle’s service:
    class FallbackAuthServiceDecorator implements AuthServiceInterface {
        private $decorated;
    
        public function __construct(AuthServiceInterface $decorated) {
            $this->decorated = $decorated;
        }
    
        public function authenticate() {
            try {
                return $this->decorated->authenticate();
            } catch (\Exception $e) {
                // Fallback logic
            }
        }
    }
    
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.
headercat/phpstan-extension-ide-helper
yosymfony/parser-utils
innmind/black-box
babenkoivan/elastic-migrations
babenkoivan/elastic-adapter
sandermuller/package-boost-php
sandermuller/boost-core
depa/sulu-google-reviews-bundle
croct/plug-symfony
develia/commons
dmstr/symfony-system-resources-bundle
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
renatomarinho/laravel-page-speed
develia/geo-bundle
austinheap/laravel-database-encryption
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
imbo/imbo-coding-standard