Convert Figma logo to code with AI

w7corp logoeasywechat

📦 一个 PHP 微信 SDK

10,264
2,405
10,264
2

Top Related Projects

78,107

Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation for your next big idea — freeing you to create without sweating the small things.

📦 一个 PHP 微信 SDK

5,011

可能是我用过的最优雅的 Alipay/WeChat/Douyin/Unipay/江苏银行 的支付 SDK 扩展包了

可能是我用过的最优雅的 Alipay/WeChat/Unipay 的 laravel 支付扩展包了

Quick Overview

The w7corp/easywechat project is a comprehensive and user-friendly SDK for building WeChat applications in PHP. It provides a set of APIs and tools to interact with various WeChat services, including official accounts, mini-programs, payment, and more.

Pros

  • Comprehensive Functionality: The SDK covers a wide range of WeChat features, making it a one-stop solution for building WeChat-based applications.
  • Ease of Use: The project has a well-designed and intuitive API, making it easy for developers to integrate WeChat functionality into their applications.
  • Active Development: The project is actively maintained, with regular updates and bug fixes, ensuring compatibility with the latest WeChat platform changes.
  • Extensive Documentation: The project comes with detailed documentation, including examples and guides, which helps developers get started quickly.

Cons

  • Dependency on WeChat Platform: The SDK is tightly coupled with the WeChat platform, which means that any changes or updates to the WeChat API may require updates to the SDK.
  • Limited Support for Non-PHP Environments: The SDK is primarily designed for PHP-based applications, and may not be as well-suited for projects in other programming languages.
  • Potential Learning Curve: While the SDK is generally easy to use, developers who are new to WeChat development may still face a learning curve when getting started with the project.
  • Limited Community Support: Compared to some other popular PHP libraries, the w7corp/easywechat project may have a smaller community of contributors and users, which could impact the availability of support and resources.

Code Examples

Here are a few examples of how to use the w7corp/easywechat SDK:

  1. Sending a Text Message to a WeChat Official Account:
use EasyWeChat\Factory;

$config = [
    'app_id' => 'your-app-id',
    'secret' => 'your-app-secret',
    // ... other configurations
];

$app = Factory::officialAccount($config);

$response = $app->customer_service->message('text')
                                 ->from('from-user-id')
                                 ->to('to-user-id')
                                 ->content('Hello, WeChat!')
                                 ->send();
  1. Handling a WeChat Mini-Program Event:
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;
use EasyWeChat\Kernel\Contracts\MessageInterface;

class MyEventHandler implements EventHandlerInterface
{
    public function handle(MessageInterface $message): MessageInterface
    {
        // Handle the event here
        if ($message->getMsgType() === 'event') {
            // Handle the event
            if ($message->getEvent() === 'subscribe') {
                // Handle the subscribe event
                return $message->reply('Welcome to my mini-program!');
            }
        }

        return $message;
    }
}

$app = Factory::miniProgram($config);
$app->server->push(MyEventHandler::class);
$app->server->serve()->send();
  1. Initiating a WeChat Payment:
use EasyWeChat\Factory;

$config = [
    'app_id' => 'your-app-id',
    'mch_id' => 'your-mch-id',
    'key' => 'your-api-key',
    // ... other configurations
];

$app = Factory::payment($config);

$result = $app->order->unify([
    'body' => 'Your Order',
    'out_trade_no' => 'unique-order-no',
    'total_fee' => 1, // 0.01 CNY
    'notify_url' => 'https://example.com/payments/notify',
    'trade_type' => 'JSAPI',
    'openid' => 'user-open-id',
]);

if ($result->return_code == 'SUCCESS' && $result->result_code == 'SUCCESS') {
    $prepayId = $result->prepay_id;
    // Generate the payment parameters and return them to the client
}

Competitor Comparisons

78,107

Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation for your next big idea — freeing you to create without sweating the small things.

Pros of laravel/laravel

  • Comprehensive and well-documented framework, providing a robust set of tools and features for building web applications.
  • Large and active community, with a wealth of resources, packages, and third-party integrations available.
  • Emphasis on convention over configuration, which can speed up development and promote consistency.

Cons of laravel/laravel

  • Steeper learning curve compared to EasyWeChat, especially for developers new to the Laravel ecosystem.
  • Larger codebase and more complex structure, which can make it more challenging to understand and customize for specific use cases.
  • Potential performance overhead compared to a more lightweight solution like EasyWeChat.

Code Comparison

laravel/laravel (5 lines)

Route::get('/', function () {
    return view('welcome');
});

Route::get('/dashboard', function () {
    return view('dashboard');
});

w7corp/easywechat (5 lines)

$app = Factory::officialAccount([
    'app_id' => 'your-app-id',
    'secret' => 'your-app-secret',
    'token' => 'your-token',
    'aes_key' => 'your-aes-key',
]);

📦 一个 PHP 微信 SDK

Pros of EasyWeChat

  • Comprehensive and well-documented functionality for interacting with the WeChat API
  • Active community and regular updates to keep up with WeChat platform changes
  • Supports a wide range of WeChat features, including payment, official accounts, and more

Cons of EasyWeChat

  • Larger codebase and more complex setup compared to some other WeChat SDK options
  • May have a steeper learning curve for developers new to the WeChat ecosystem
  • Potential performance overhead for smaller or simpler WeChat integrations

Code Comparison

EasyWeChat:

$app = Factory::officialAccount([
    'app_id' => 'your-app-id',
    'secret' => 'your-app-secret',
    // 'token' => 'your-token',
    // 'aes_key' => 'your-aes-key',
]);

$response = $app->server->serve();

EasyWeChat (v2):

$app = new Application([
    'app_id' => 'your-app-id',
    'secret' => 'your-app-secret',
    // 'token' => 'your-token',
    // 'aes_key' => 'your-aes-key',
]);

$response = $app->server->serve();

The main difference is the use of the Factory class in the original EasyWeChat library, compared to the direct Application class instantiation in the v2 version.

5,011

可能是我用过的最优雅的 Alipay/WeChat/Douyin/Unipay/江苏银行 的支付 SDK 扩展包了

Pros of yansongda/pay

  • Supports a wider range of payment gateways, including Alipay, WeChat Pay, and UnionPay.
  • Provides a more comprehensive set of features, such as refunds, transfers, and recurring payments.
  • Offers better documentation and more active community support.

Cons of yansongda/pay

  • May have a steeper learning curve for developers already familiar with EasyWeChat.
  • Potentially less optimized for WeChat-specific use cases compared to EasyWeChat.
  • May have a larger codebase and dependencies, which could impact performance in some scenarios.

Code Comparison

EasyWeChat:

$app = Factory::officialAccount([
    'app_id' => 'your-app-id',
    'secret' => 'your-app-secret',
    'token' => 'your-token',
    'aes_key' => 'your-aes-key',
]);

$response = $app->server->serve();

yansongda/pay:

$alipay = Pay::alipay([
    'app_id' => 'your-app-id',
    'notify_url' => 'http://example.com/notify',
    'return_url' => 'http://example.com/return',
    'ali_public_key' => 'path/to/ali_public_key.pem',
    'private_key' => 'path/to/private_key.pem',
    'log' => [
        'file' => './logs/alipay.log',
        'level' => 'debug',
        'type' => 'single',
    ],
]);

可能是我用过的最优雅的 Alipay/WeChat/Unipay 的 laravel 支付扩展包了

Pros of Laravel Pay

  • Comprehensive Payment Gateway Support: Laravel Pay supports a wide range of payment gateways, including Alipay, WeChat Pay, UnionPay, and more, making it a versatile solution for various payment needs.
  • Intuitive API: The API provided by Laravel Pay is straightforward and easy to use, simplifying the integration process for developers.
  • Laravel Integration: As a Laravel-specific package, Laravel Pay seamlessly integrates with the Laravel framework, allowing developers to leverage the ecosystem's features and best practices.

Cons of Laravel Pay

  • Limited to Laravel: While the tight integration with Laravel is a strength, it also means that Laravel Pay is not suitable for non-Laravel projects, limiting its broader applicability.
  • Fewer Contributors: Compared to EasyWeChat, Laravel Pay has a smaller community and fewer contributors, which may impact the pace of development and the availability of support.
  • Narrower Scope: EasyWeChat covers a broader range of WeChat-related features, while Laravel Pay is primarily focused on payment processing, potentially limiting its usefulness for more complex WeChat integrations.

Code Comparison

EasyWeChat:

$app = Factory::officialAccount([
    'app_id' => 'your-app-id',
    'secret' => 'your-app-secret',
    // 'token' => 'your-token',
    // 'aes_key' => 'your-aes-key',
]);

$response = $app->server->serve();

Laravel Pay:

$alipay = Pay::alipay([
    'app_id' => 'your-app-id',
    'secret' => 'your-app-secret',
    'key' => 'your-key',
    'return_url' => 'https://example.com/alipay/return',
    'notify_url' => 'https://example.com/alipay/notify',
]);

$alipay->web([
    'out_trade_no' => time(),
    'total_amount' => 1,
    'subject' => 'Test Order',
])->send();

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

EasyWeChat

📦 一个 PHP 微信开发 SDK,开源 SaaS 平台提供商 微擎 旗下开源产品。

Test Status Lint Status Latest Stable Version Latest Unstable Version Total Downloads License

环境需求

安装

composer require w7corp/easywechat

使用示例

基本使用(以公众号服务端为例):

<?php

use EasyWeChat\OfficialAccount\Application;

$config = [
    'app_id' => 'wx3cf0f39249eb0exxx',
    'secret' => 'f1c242f4f28f735d4687abb469072xxx',
    'aes_key' => 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG',
    'token' => 'easywechat',
];

$app = new Application($config);

$server = $app->getServer();

$server->with(fn() => "您好!EasyWeChat!");

$response = $server->serve();

文档和链接

官网 · 讨论 · 更新策略

:heart: 支持我

如果你喜欢我的项目并想支持它,点击这里 :heart:

由 JetBrains 赞助

非常感谢 Jetbrains 为我提供的 IDE 开源许可,让我完成此项目和其他开源项目上的开发工作。

可爱的贡献者们

License

MIT