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

Instagram Bundle Laravel Package

beloop/instagram-bundle

Read-only Symfony bundle from the Beloop LMS component suite. Licensed under MIT. Development, issues, questions, and pull requests are handled in the main beloop/components repository, not in this package.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the bundle via Composer (though note the package is archived and unmaintained):

    composer require beloop/instagram-bundle
    

    Register the bundle in config/bundles.php:

    Beloop\InstagramBundle\BeloopInstagramBundle::class => ['all' => true],
    
  2. Configuration Configure the bundle in config/packages/beloop_instagram.yaml:

    beloop_instagram:
        client_id: '%env(INSTAGRAM_CLIENT_ID)%'
        client_secret: '%env(INSTAGRAM_CLIENT_SECRET)%'
        redirect_uri: '%env(INSTAGRAM_REDIRECT_URI)%'
    
  3. First Use Case: OAuth Flow Trigger the OAuth flow in a controller:

    use Beloop\InstagramBundle\Controller\InstagramController;
    
    class MyController extends AbstractController
    {
        public function instagramLogin(InstagramController $controller)
        {
            return $controller->login();
        }
    }
    

    Route it in config/routes.yaml:

    instagram_login:
        path: /login/instagram
        controller: App\Controller\MyController::instagramLogin
    

Implementation Patterns

Workflow: User Authentication & Data Fetching

  1. OAuth Flow

    • Redirect users to Instagram for authentication via login().
    • Handle the callback at /login/instagram/check (default route).
    • Use the InstagramService to fetch user data:
      $userData = $this->get('beloop_instagram.service')->getUserData($accessToken);
      
  2. Media Integration Fetch user media (photos/videos) with pagination:

    $media = $this->get('beloop_instagram.service')->getUserMedia($accessToken, [
        'count' => 10,
        'offset' => 0,
    ]);
    
  3. Event-Driven Extensions Subscribe to bundle events (e.g., instagram.login.success) to extend logic:

    // src/EventListener/InstagramLoginListener.php
    public function onInstagramLoginSuccess(InstagramLoginEvent $event)
    {
        $user = $event->getUser();
        // Custom logic (e.g., sync with your DB)
    }
    

    Register the listener in services.yaml:

    services:
        App\EventListener\InstagramLoginListener:
            tags:
                - { name: 'kernel.event_listener', event: 'instagram.login.success' }
    

Gotchas and Tips

Pitfalls

  1. Deprecated API

  2. No Active Maintenance

    • The bundle lacks updates for PHP 8.x or Symfony 5/6. Test thoroughly in a staging environment.
    • Use at your own risk; no support for issues/PRs.
  3. Token Expiry

    • Access tokens expire (~1 hour). Implement token refresh logic or store short-lived tokens:
      $service->refreshAccessToken($refreshToken);
      

Debugging

  • Enable Debug Mode Add to config/packages/beloop_instagram.yaml:

    debug: true
    

    Logs HTTP requests/responses to var/log/dev.log.

  • Common Errors

    • Invalid OAuth state: Ensure redirect_uri matches Instagram’s registered URI.
    • Missing permissions: Request user_media scope explicitly in the OAuth flow.

Extension Points

  1. Custom Services Extend Beloop\InstagramBundle\Service\InstagramService to add methods (e.g., getUserStories()).

  2. Twig Integration Pass user/media data to templates:

    {% for media in instagram_media %}
        <img src="{{ media.images.standard_resolution.url }}">
    {% endfor %}
    
  3. Database Sync Use Doctrine listeners to sync Instagram data:

    // src/EventListener/InstagramMediaSyncListener.php
    public function postLoad(User $user, InstagramMediaEvent $event)
    {
        $user->addInstagramMedia($event->getMedia());
        $this->entityManager->flush();
    }
    
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity