- How do I install socialiteproviders/wechat-web in a Laravel app?
- Run composer require socialiteproviders/wechat-web. It pulls in socialiteproviders/manager, which wires the provider into Socialite through the event system. On a modern Laravel app expect dependency conflicts, because the last release is from 2020 and targets Laravel 8-era packages. Try it on a branch and confirm it resolves before committing.
- Which Laravel and PHP versions does wechat-web support?
- The package was last released on 2020-12-01 and declares illuminate/support and socialiteproviders/manager constraints from the Laravel 8 era. Laravel 9, 10 and 11 plus PHP 8.1 and newer are not declared and will likely fail composer require. Socialite AbstractProvider signature changes can also produce fatals. Treat anything above Laravel 8 and PHP 8.0 as unproven until you spike it.
- How do I configure the WeChat driver in config/services.php?
- Add a wechat block to config/services.php with client_id set to the AppID, client_secret set to the AppSecret, and redirect set to your callback URL. The redirect domain must match the authorized callback domain on the WeChat Open Platform website app. Then call Socialite::driver('wechat')->redirect() and handle the callback with ->user().
- How do I register the SocialiteWasCalled listener for this provider?
- Listen for SocialiteWasCalled in app/Providers/EventServiceProvider and call the package's event listener class. Without that listener Socialite throws a Driver [wechat] not supported error. The exact listener class follows the SocialiteProviders convention and is shown in the readme. Clear your config and event caches after adding it.
- Does this package handle WeChat error codes like 40029 or 40163?
- WeChat returns failures as HTTP 200 responses containing errcode and errmsg, for example 40029 for an invalid code and 40163 for a code that was already used. Without explicit checks this yields a null user rather than an exception. Wrap ->user() in your own validation of the token and profile before creating a session. Log the errcode so failed logins are diagnosable.
- What is the difference between openid and unionid in this WeChat provider?
- openid identifies a user within a single WeChat app and is always returned. unionid is only present when the website app is bound to the same WeChat Open Platform account as the user's other channels. Keying accounts on openid silently fragments identities across web, 公众号 and mini-program logins. If you need cross-channel linking, map on unionid and handle the case where it is missing.
- Can wechat-web handle login inside the WeChat in-app browser?
- No. The 网站应用 flow is QR-code based, and a user already inside WeChat's in-app browser cannot scan a QR code shown on their own screen. wechat-web covers desktop and non-WeChat mobile browsers only. In-app traffic needs the 公众号 OAuth driver with snsapi_userinfo, which is a separate provider. Plan for two drivers if in-app login matters.
- How do I test WeChat login without a real AppID?
- You cannot complete a real QR login without a 网站应用 AppID on a verified Open Platform account, so mock the Socialite driver or fake the HTTP calls to open.weixin.qq.com. Assert your callback handling for errcode responses such as 40029 and 40163, and for a profile with no unionid. Keep a manual smoke test against a credentialed environment before release.
- Is socialiteproviders/wechat-web still maintained, and what are the alternatives?
- The repository is a READ ONLY subtree split of SocialiteProviders/Providers, so fixes must land in the monorepo and may never arrive here. With no release since 2020, you are effectively the maintainer for any Laravel or PHP upgrade. A custom provider of roughly 150 lines extending Socialite's AbstractProvider is the recommended alternative. It gives you full control of error handling, unionid mapping and version compatibility.
- What credentials do I need from the WeChat Open Platform and how long do they take?
- You need a 网站应用 AppID and AppSecret from a verified WeChat Open Platform account, which requires a Chinese business licence and an annual certification fee of about ¥300. The callback domain must be ICP-filed. Obtaining the credential typically takes two to six weeks of calendar time. That is far longer than the one to two days of coding.