PHPackages                             ollieltd/instagram-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ollieltd/instagram-bundle

ActiveSymfony-bundle

ollieltd/instagram-bundle
=========================

Use Instaphp by sesser (Randy) as a Symfony2 service. Adapted to use Instaphp v2 as a dependency.

1019.8k↓50%12[6 issues](https://github.com/ollieLtd/InstagramBundle/issues)[1 PRs](https://github.com/ollieLtd/InstagramBundle/pulls)PHP

Since Jul 9Pushed 6y ago2 watchersCompare

[ Source](https://github.com/ollieLtd/InstagramBundle)[ Packagist](https://packagist.org/packages/ollieltd/instagram-bundle)[ RSS](/packages/ollieltd-instagram-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

OhInstagramBundle
=================

[](#ohinstagrambundle)

Uses [Instaphp](https://github.com/sesser/instaphp) by [sesser](https://github.com/sesser) as a Symfony2 service. Adapted to use Instaphp v2 as a dependency.

Installation
------------

[](#installation)

Install this bundle as usual by adding to composer.json:

```
"ollieltd/instagram-bundle": "dev-master"
```

After installing above module you need to update your composer

```
composer update
```

Register the bundle in `app/AppKernel.php`:

```
// app/AppKernel.php
public function registerBundles()
{
    return [
        // ...
        new Oh\InstagramBundle\OhInstagramBundle(),
    ];
}
```

Add the following to `app/config/config.yml`:

```
imports:
    - { resource: "@OhInstagramBundle/Resources/config/services.yml" }

oh_instagram:
    instaphp:
        config:
            client_id: %instagram_api_client_id%
            client_secret: %instagram_api_client_secret%
            access_token: %instagram_api_access_token% # (optional)
```

And add these parameters:

```
instagram_api_client_id: YOUR_API_ID
instagram_api_client_secret: YOUR_API_SECRET
instagram_api_access_token: YOUR_API_ACCESS_TOKEN # (optional)
```

Most of the Instaphp configuration keys can be set in `oh_instagram.instaphp.config`. See [Configuring Instaphp](Resources/docs/Instaphp.md)

And if you're OK with the provided routes, add these to `app/config/routing.yml`:

```
OhInstagramBundle:
    resource: "@OhInstagramBundle/Resources/config/routing.yml"
    prefix:   /
```

Usage (Controller)
------------------

[](#usage-controller)

```
$query = "snoopdogg";

/**
 * @var InstaphpAdapter
 */
$api = $this->get('instaphp');

$userId = $api->Users->FindId($query);
$media = $api->Users->Recent($userId);
```

You can also test if a user is logged in:

```
//is a user logged in?
$loggedIn = $this->get('instaphp_token_handler')->isLoggedIn();
```

Usage (Twig)
------------

[](#usage-twig)

You should set up your [Instagram API account](http://instagram.com/developer/clients/manage) to callback to the `OhInstagramBundle_callback` route, which you can set yourself, or use the one provided which is `http://yourserver.com/instaphp/callback`.

For quick testing purposes you can add this to your routing:

```
OhInstagramBundle_check:
    path: /checkInstagram
    defaults: { _controller: OhInstagramBundle:Instagram:instagramLoginStatus }
```

Then navigate to `/checkInstagram` to try out the login button.

There's a login button included in the views. Just implement this line in your Twig template:

```
{{ render(controller('OhInstagramBundle:Instagram:instagramLoginStatus')) }}
```

Instagram Auth Token
--------------------

[](#instagram-auth-token)

There are 2 TokenHandlers included:

### CookieToken

[](#cookietoken)

The Instagram auth code is stored in a cookie

```
services:
    instaphp_token_handler:
        class: Oh\InstagramBundle\TokenHandler\CookieToken
```

### UserToken

[](#usertoken)

The Instagram auth code is stored in the User Entity. The methods `setInstagramAuthCode()` and `getInstagramAuthCode()` must be implemented on your User. When the login call is returned from Instagram, the code is set and the user is persisted and flushed in the Handler. There is an interface which is recommended that you use on your entity: `Oh\InstagramBundle\TokenHandler\UserTokenInterface`

```
services:
    instaphp_token_handler:
        class: Oh\InstagramBundle\TokenHandler\UserToken
            arguments: ["@security.context", "@doctrine.orm.default_entity_manager"]
```

### Both

[](#both)

This will look to see if the user can be retrieved from the context and if it can't it will store the auth code in a cookie.

```
services:
    instaphp_user_token_handler:
        class: Oh\InstagramBundle\TokenHandler\UserToken
        arguments: ["@security.context", "@doctrine.orm.default_entity_manager"]
    instaphp_cookie_token_handler:
        class: Oh\InstagramBundle\TokenHandler\CookieToken
    instaphp_token_handler:
        class: Oh\InstagramBundle\TokenHandler\TokenManager
        arguments: ["@instaphp_user_token_handler", "@instaphp_cookie_token_handler"]
```

You can also implement your own TokenHandlerInterface to store the auth code somewhere else, for example in the session.

Tests
-----

[](#tests)

@todo

Credits
-------

[](#credits)

- Ollie Harridge (ollietb) as the author.
- Randy (sesser) for writing [Instaphp](https://github.com/sesser/instaphp)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance8

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 67.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c292a6c56c272b9c31da4a195de55521accd66989e84cd7e0767423a6743a275?d=identicon)[ollietb](/maintainers/ollietb)

---

Top Contributors

[![ollietb](https://avatars.githubusercontent.com/u/342090?v=4)](https://github.com/ollietb "ollietb (43 commits)")[![rmasters](https://avatars.githubusercontent.com/u/34284?v=4)](https://github.com/rmasters "rmasters (8 commits)")[![stephen-crowdreactive](https://avatars.githubusercontent.com/u/8859564?v=4)](https://github.com/stephen-crowdreactive "stephen-crowdreactive (3 commits)")[![bakl](https://avatars.githubusercontent.com/u/10196392?v=4)](https://github.com/bakl "bakl (3 commits)")[![ramireddy558](https://avatars.githubusercontent.com/u/7223426?v=4)](https://github.com/ramireddy558 "ramireddy558 (2 commits)")[![nouchka](https://avatars.githubusercontent.com/u/4774393?v=4)](https://github.com/nouchka "nouchka (2 commits)")[![BulgakowS](https://avatars.githubusercontent.com/u/1461444?v=4)](https://github.com/BulgakowS "BulgakowS (1 commits)")[![barbieswimcrew](https://avatars.githubusercontent.com/u/9333471?v=4)](https://github.com/barbieswimcrew "barbieswimcrew (1 commits)")[![satellitecam](https://avatars.githubusercontent.com/u/111709625?v=4)](https://github.com/satellitecam "satellitecam (1 commits)")

### Embed Badge

![Health badge](/badges/ollieltd-instagram-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/ollieltd-instagram-bundle/health.svg)](https://phpackages.com/packages/ollieltd-instagram-bundle)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
