PHPackages                             tourze/qq-connect-oauth2-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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. tourze/qq-connect-oauth2-bundle

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

tourze/qq-connect-oauth2-bundle
===============================

A Symfony bundle for integrating QQ Connect OAuth2 authentication into your application

0.0.1(7mo ago)00MITPHPCI passing

Since Nov 18Pushed 6mo agoCompare

[ Source](https://github.com/tourze/qq-connect-oauth2-bundle)[ Packagist](https://packagist.org/packages/tourze/qq-connect-oauth2-bundle)[ RSS](/packages/tourze-qq-connect-oauth2-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (37)Versions (2)Used By (0)

QQConnectOAuth2Bundle
=====================

[](#qqconnectoauth2bundle)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/f1c850d4e1d391655e7e45c4d0f8f95a250bfcc1f84b61c043f6a8f062963925/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f71712d636f6e6e6563742d6f61757468322d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/qq-connect-oauth2-bundle)[![PHP Version](https://camo.githubusercontent.com/150e1fb3defd53b8f722bfb7cea27d0f7f129d8d8d472e092c6696a326bd69a4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d626c75652e7376673f7374796c653d666c61742d737175617265)](https://www.php.net/)[![Symfony Version](https://camo.githubusercontent.com/96232085dc51b5b3fead321111ed57b50fd9a3d6a96175a00f828aa293fb0a14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73796d666f6e792d253345253344372e332d677265656e2e7376673f7374796c653d666c61742d737175617265)](https://symfony.com/)[![License](https://camo.githubusercontent.com/6c711032aff1ca0eb6b211aa6cb3649ce7fd64a7714e1181d4bb457f9680e7cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Tests](https://camo.githubusercontent.com/276971ffedf1e07528a7f7506431868ac1f8ad59185e51ea69a4b6a10153e4da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d3130332532307061737365642d677265656e2e7376673f7374796c653d666c61742d737175617265)](#)[![Coverage](https://camo.githubusercontent.com/994d68acb2aadf1c3c7711ddcb3b30429246a6c05da9e601f62c3f932ac795a8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](#)

A Symfony bundle for integrating QQ Connect OAuth2 authentication into your application.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Configuration](#configuration)
- [Usage](#usage)
- [CLI Commands](#cli-commands)
- [Entities](#entities)
- [Advanced Usage](#advanced-usage)
- [Security](#security)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)

Features
--------

[](#features)

- Complete QQ OAuth2 flow implementation
- Entity-based configuration management with automatic timestamp tracking
- Automatic route registration via RoutingAutoLoaderBundle
- Automatic redirect URI generation from routing
- Token refresh support via CLI commands
- User information retrieval
- CLI commands for configuration and maintenance
- Multiple QQ app support (each user/state linked to specific config)

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

[](#installation)

```
composer require tourze/qq-connect-oauth2-bundle
```

### Requirements

[](#requirements)

- PHP &gt;= 8.1
- Symfony &gt;= 7.3
- Doctrine ORM
- Symfony HttpClient

Quick Start
-----------

[](#quick-start)

1. Install the bundle:

```
composer require tourze/qq-connect-oauth2-bundle
```

2. Update your database schema:

```
php bin/console doctrine:schema:update --force
```

3. Create QQ OAuth2 configuration:

```
php bin/console qq-oauth2:config create \
    --app-id="YOUR_APP_ID" \
    --app-secret="YOUR_APP_SECRET" \
    --scope="get_user_info"
```

4. Use in your template:

```
Login with QQ
```

Configuration
-------------

[](#configuration)

### Routes

[](#routes)

The bundle automatically registers the following routes:

- `/qq-oauth2/login` - Initiate QQ login
- `/qq-oauth2/callback` - OAuth callback handler

**Note**: The redirect URI is automatically generated based on your routing configuration. Make sure your QQ application is configured with the correct callback URL: `https://yourdomain.com/qq-oauth2/callback`

### Bundle Dependencies

[](#bundle-dependencies)

This bundle automatically includes and configures:

- Tourze DoctrineTimestampBundle - for automatic timestamp management
- Tourze DoctrineIndexedBundle - for automatic index management
- Tourze BundleDependency - for proper bundle dependency resolution

Usage
-----

[](#usage)

### Basic Login Flow

[](#basic-login-flow)

```
// In your controller or template
Login with QQ
```

### Get User Information

[](#get-user-information)

```
use Tourze\QQConnectOAuth2Bundle\Service\QQOAuth2Service;

class YourController
{
    public function __construct(
        private QQOAuth2Service $qqOAuth2Service
    ) {}

    public function getUserInfo(string $openid): array
    {
        return $this->qqOAuth2Service->getUserInfo($openid);
    }
}
```

### Refresh Tokens via Command

[](#refresh-tokens-via-command)

```
# Refresh a specific user's token
php bin/console qq-oauth2:refresh-token test_openid

# Refresh all expired tokens
php bin/console qq-oauth2:refresh-token --all

# Dry run to see what would be refreshed
php bin/console qq-oauth2:refresh-token --all --dry-run
```

CLI Commands
------------

[](#cli-commands)

### Manage configurations

[](#manage-configurations)

```
# List all configurations
php bin/console qq-oauth2:config list

# Update configuration
php bin/console qq-oauth2:config update --id=1 --enabled=false

# Delete configuration
php bin/console qq-oauth2:config delete --id=1

# Clean up expired states
php bin/console qq-oauth2:cleanup
```

Entities
--------

[](#entities)

The bundle provides three main entities:

1. **QQOAuth2Config** - Stores OAuth application configuration (App ID, App Secret, etc.)
2. **QQOAuth2State** - Manages OAuth state for security (linked to QQOAuth2Config)
3. **QQOAuth2User** - Stores QQ user information and tokens (linked to QQOAuth2Config)

Advanced Usage
--------------

[](#advanced-usage)

### Custom Event Handling

[](#custom-event-handling)

You can listen to OAuth events by creating custom event listeners:

```
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class QQOAuthEventSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents(): array
    {
        return [
            'qq_oauth.user_authenticated' => 'onUserAuthenticated',
        ];
    }

    public function onUserAuthenticated($event): void
    {
        // Handle successful authentication
    }
}
```

### Extended Configuration

[](#extended-configuration)

For complex scenarios, you can extend the service:

```
use Tourze\QQConnectOAuth2Bundle\Service\QQOAuth2Service;

class CustomQQOAuth2Service extends QQOAuth2Service
{
    public function customUserInfoProcessing(array $userInfo): array
    {
        // Add custom processing logic
        return $userInfo;
    }
}
```

Security
--------

[](#security)

This bundle implements several security measures:

- **State Parameter**: Prevents CSRF attacks during OAuth flow
- **Token Validation**: Validates all tokens received from QQ
- **Secure Storage**: User tokens are stored securely in the database
- **Automatic Cleanup**: Expired states are automatically cleaned up

### Security Best Practices

[](#security-best-practices)

1. Always use HTTPS in production
2. Regularly clean up expired tokens using the provided commands
3. Monitor for suspicious OAuth activities
4. Keep your QQ application secrets secure

Testing
-------

[](#testing)

```
vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for details.

License
-------

[](#license)

MIT

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

229d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13899502?v=4)[tourze](/maintainers/tourze)[@tourze](https://github.com/tourze)

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-qq-connect-oauth2-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-qq-connect-oauth2-bundle/health.svg)](https://phpackages.com/packages/tourze-qq-connect-oauth2-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M737](/packages/sylius-sylius)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)[contao/core-bundle

Contao Open Source CMS

1231.6M2.8k](/packages/contao-core-bundle)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M577](/packages/shopware-core)

PHPackages © 2026

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