ollieltd/instagram-bundle
ollieltd/instagram-bundle provides a straightforward Instagram integration for Symfony/PHP applications, offering configuration and services for API credentials, fetching feeds, and exposing Instagram data to controllers and templates.
This is a Symfony2 bundle, not a Laravel package, so "getting started" in a Laravel app really means deciding whether you want to carry a Symfony DI shim into a Laravel codebase. For most teams the answer is no; treat this as a reference implementation of wiring Instaphp v2 into a container rather than something you composer require into app/Providers.
Minimal path if you proceed:
composer require ollieltd/instagram-bundle (pin it; the Instaphp v2 dependency is ancient and may not resolve cleanly on modern PHP — check composer why-not if install fails).DependencyInjection/ extension and Resources/config/services.yml — that is where the Instaphp client is constructed and which config keys (client ID, client secret, redirect URI, scopes) are injected.getLoginUrl, callback handling, token storage), because the bundle itself does little beyond service registration.services.yml construction and returns an Instaphp\InstagramAPI instance.First use case to prove it works: authenticate a single account and fetch that user's recent media (/users/self/media/recent equivalent in Instaphp v2), then dump the raw response. Do not build on top of it until you have confirmed the HTTP layer actually reaches Instagram with a valid token — most failures here are auth/token issues, not bundle issues.
Container bridging (Symfony intent). The bundle's value is a service definition that injects config into Instaphp v2. If you are in Symfony, enable the bundle in AppKernel, put credentials under the bundle's config key, and inject the service into your controllers/services by type-hint or service id.
Laravel adaptation. Since Laravel has no bundle/extension mechanism, reproduce it in a service provider:
$this->app->singleton(\Instaphp\InstagramAPI::class, function ($app) {
$config = $app['config']->get('services.instagram');
return new \Instaphp\InstagramAPI(
$config['client_id'],
$config['client_secret'],
$config['redirect_uri'],
$config['scope'] ?? ['basic']
);
});
Then resolve it via constructor injection rather than app() calls, so you can swap a fake in tests.
Auth/token workflow. Typical pattern is a two-route flow: a "connect" route that redirects to the Instaphp-generated login URL, and a callback route that exchanges the code for an access token. Persist the token (and Instagram user id) in your own table — the bundle/Instaphp v2 does not give you durable token storage you should rely on. Treat tokens as user-owned data so you can support multiple accounts and re-auth.
Service-layer wrapper. Don't sprinkle Instaphp calls through controllers. Wrap it in a small InstagramClient service exposing domain methods (recentMedia($userId), userProfile($userId), like($mediaId)), and have that wrapper own the Instaphp instance, error mapping, and rate-limit backoff. This is the single most useful pattern because it isolates you from the library's array-heavy responses and from a future replacement.
Integration tips.
register() a Symfony bundle the normal way. There is no auto-discovery, no config/instagram.php merge, no facade. Expect to copy configuration semantics out of DependencyInjection/Configuration.php by hand.symfony/* constraints and PHP versions that conflict with a modern Laravel skeleton. If Composer refuses, do not fight it — vendor the handful of relevant classes or, better, use a current Instagram client.redirect_uri or mismatched scopes produce opaque OAuth errors from Instagram rather than clear exceptions; log the outgoing authorize URL and compare it to the app's registered redirect URI exactly (scheme, trailing slash, port).meta.code, and translate to your own exceptions. Silent null/empty-array returns usually mean an expired token, not "no data".expires_at, and add a scheduled job or middleware that flags accounts needing re-authentication.services.yml/compiler pass; Laravel: container binding) to substitute your own client. Do not subclass the bundle's classes — they are thin and unstable.How can I help you explore Laravel packages today?