PaoZhu 项目概述

框架简介

Paozhu 是一个面向 C++ 的全栈 Web 框架,强调「为 C++ Web 快速开发而生」。

核心特点包括:原生 HTTP/1.1、HTTP/2 解析;协程与线程池分离的 I/O 模型(类似 Go 调度思想);内置 ORM、WebSocket、RPC、缓存、压缩等能力;通过注解自动发现路由并注册控制器方法;支持视图渲染与模板。

核心特性

高性能异步 I/O

基于 ASIO 的协程调度,实现高效并发处理

🔧

注解驱动开发

//@urlpath 注解自动注册路由,无需手动配置

🗄️

内置 ORM

支持 MySQL 和 PostgreSQL,简化数据库操作

🔌

WebSocket 支持

原生 WebSocket 客户端和服务端支持

🎨

视图系统

灵活的模板渲染引擎,支持视图缓存

💻

多平台支持

Linux / macOS / Windows 全平台兼容

可选功能

PDF 生成、Excel 读写、Word 读写、ZIP 压缩、短信发送、支付集成等

PDF 生成 Excel 读写 Word 读写 ZIP 压缩 短信发送 支付集成

技术栈

C++20 标准 Asio (ASIO_STANDALONE) OpenSSL ZLIB / Brotli CMake / Xmake 构建系统 vcpkg 包管理

项目结构

以下是 PaoZhu 项目的典型目录结构:


startup/          启动入口
├── main_daemon.cpp     守护进程模式
└── main_dev.cpp        开发模式

common/           公共组件
├── 自动控制器注册
└── 路由注册等

controller/       业务控制器
├── src/                示例代码
└── include/            头文件

viewsrc/          视图系统
orm/              ORM 数据访问
conf/             配置文件
├── server.conf         服务器配置
└── orm.conf            数据库配置
                

快速开始示例代码

Hello World 示例:


#include "httppeer.h"
#include "testhello.h"
namespace http
{
//@urlpath(null,hello)
std::string testhello(std::shared_ptr<httppeer> peer)
{
    httppeer &client = peer->get_peer();
    client << " Hello world! Paozhu c++ web framework ";
    return "";
}
}
                

PaoZhu Project Overview

Framework Overview

Paozhu is a full-stack Web framework for C++, emphasizing "rapid Web development for C++".

Core features include: native HTTP/1.1 and HTTP/2 parsing; an I/O model separating coroutines and thread pools (similar to Go's scheduling philosophy); built-in ORM, WebSocket, RPC, caching, compression capabilities; automatic route discovery and controller method registration through annotations; support for view rendering and templates.

Core Features

High-Performance Async I/O

Coroutine-based scheduling powered by ASIO for efficient concurrency

🔧

Annotation-Driven Development

//@urlpath annotations automatically register routes, no manual config needed

🗄️

Built-in ORM

Supports MySQL and PostgreSQL, simplifies database operations

🔌

WebSocket Support

Native WebSocket client and server support

🎨

View System

Flexible template rendering engine with view caching support

💻

Cross-Platform

Full compatibility across Linux, macOS, and Windows

Optional Features

PDF generation, Excel read/write, Word read/write, ZIP compression, SMS sending, payment integration, etc.

PDF Generation Excel Read/Write Word Read/Write ZIP Compression SMS Sending Payment Integration

Tech Stack

C++20 Standard Asio (ASIO_STANDALONE) OpenSSL ZLIB / Brotli CMake / Xmake Build System vcpkg Package Manager

Project Structure

Here is the typical directory structure of the PaoZhu project:


startup/          Entry point
├── main_daemon.cpp     Daemon mode
└── main_dev.cpp        Development mode

common/           Common components
├── Auto controller registration
└── Route registration, etc.

controller/       Business controllers
├── src/                Example code
└── include/            Header files

viewsrc/          View system
orm/              ORM data access
conf/             Configuration files
├── server.conf         Server configuration
└── orm.conf            Database configuration
                

Quick Start Example

Hello World example:


#include "httppeer.h"
#include "testhello.h"
namespace http
{
//@urlpath(null,hello)
std::string testhello(std::shared_ptr<httppeer> peer)
{
    httppeer &client = peer->get_peer();
    client << " Hello world! Paozhu c++ web framework ";
    return "";
}
}