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

Socialbar Bundle Laravel Package

azine/socialbar-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Install the Bundle

    composer require azine/socialbar-bundle
    

    Enable the bundle in config/bundles.php:

    return [
        // ...
        Azine\SocialBarBundle\AzineSocialBarBundle::class => ['all' => true],
    ];
    
  2. Configure Social Profiles Add your social profile URLs/IDs in config/packages/azine_social_bar.yaml:

    azine_social_bar:
        fb_profile_url: "https://facebook.com/yourpage"
        twitter_username: "yourhandle"
        google_plus_profile_url: "https://plus.google.com/yourprofile"
        linked_in_company_id: "12345678"
        xing_profile_url: "https://www.xing.com/profile/yourprofile"
    
  3. Render in Twig Use the azine_socialbar Twig function in your templates:

    {{ azine_socialbar() }}
    

    This renders a default social bar with buttons for Facebook, Twitter, Google+, LinkedIn, and Xing.


First Use Case: Adding a Social Bar to a Layout

Place the azine_socialbar() call in your base template (e.g., base.html.twig) to ensure it appears on every page:

<body>
    <!-- Page content -->
    {{ azine_socialbar() }}
</body>

Implementation Patterns

Dynamic Configuration

Override the default configuration per environment or per template:

# config/packages/dev/azine_social_bar.yaml
azine_social_bar:
    fb_profile_url: "https://facebook.com/devpage"

Customizing the Social Bar

Extend the Twig function or pass options:

{{ azine_socialbar({
    'show_facebook': false,
    'show_twitter': true,
    'show_google_plus': true,
    'button_style': 'standard'  // 'standard', 'box_count', or 'button_count'
}) }}

Integration with CMS or Dynamic Content

Fetch social profiles dynamically from a database:

{% set socialConfig = {
    'fb_profile_url': app.user.facebookUrl,
    'twitter_username': app.user.twitterHandle
} %}
{{ azine_socialbar(socialConfig) }}

Localization and Language Support

The bundle supports language-specific buttons (e.g., es_ES for Spanish). Pass the locale:

{{ azine_socialbar({'locale': 'es_ES'}) }}

Gotchas and Tips

Pitfalls

  1. Missing Configuration If fb_profile_url or twitter_username is empty, the corresponding buttons will not render. Validate these in your config or via Twig:

    {% if app.parameters.azine_social_bar.fb_profile_url %}
        {{ azine_socialbar({'show_facebook': true}) }}
    {% endif %}
    
  2. Button Styling Conflicts The bundle injects inline styles for buttons. If your theme overrides these, ensure specificity or use button_style: 'custom' and manually style the buttons via CSS classes (e.g., .fb-like, .twitter-follow-button).

  3. CORS Issues with LinkedIn LinkedIn’s follow button may fail if your site lacks proper CORS headers. Ensure your server allows requests to *.linkedin.com.

  4. Deprecated Symfony 3.x The bundle targets Symfony 3.x. For Symfony 4/5, test compatibility or fork the package to update dependencies (e.g., symfony/twig-bridge).


Debugging

  • Inspect Rendered HTML Check the Twig output for malformed URLs or missing attributes. Use browser dev tools to verify button scripts are loaded.

  • Clear Cache After Config Changes Run php bin/console cache:clear if buttons fail to update after modifying config/packages/azine_social_bar.yaml.

  • Validate Social URLs Test each profile URL in a browser to ensure they’re publicly accessible (e.g., LinkedIn Company IDs must be verified).


Extension Points

  1. Custom Button Templates Override the Twig template at templates/AzineSocialBar/socialbar.html.twig to modify the layout or add buttons (e.g., Pinterest, Reddit).

  2. Event Listeners Extend functionality via Symfony events. For example, listen to kernel.request to dynamically set twitter_username based on the current user:

    // src/EventListener/SocialBarListener.php
    public function onKernelRequest(GetResponseEvent $event) {
        $request = $event->getRequest();
        $this->container->getParameterBag()->set('azine_social_bar.twitter_username', $request->get('user')?->getTwitterHandle());
    }
    
  3. Add New Social Networks Fork the bundle and extend the SocialBarService to support additional platforms (e.g., Mastodon). Update the Twig template to include new buttons.


Performance Tips

  • Lazy-Load Buttons Defer non-critical buttons (e.g., Xing) by default and load them via JavaScript if needed:

    {{ azine_socialbar({'show_xing': false}) }}
    <script>
        // Load Xing button dynamically
    </script>
    
  • Combine Scripts Minify and combine the social button scripts (Facebook, Twitter, etc.) into a single file to reduce HTTP requests. Use a build tool like Webpack or Laravel Mix.

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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle