V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
2024
V2EX  ›  PHP

重造 PHP -HTTP 性能检测,新增 List<int>、HashMap<K, V>

  •  
  •   2024 · Oct 24, 2025 · 2265 views
    This topic created in 185 days ago, the information mentioned may be changed or developed.

    https://github.com/php-any/origami

    在访问 hello work 场景下,和 go http 标准库接近,2 万左右 qps 。 text

    同时新增了更加便捷的查询

    
    $db = open("mysql", "root:root@/temp");
    
    $db->ping();
    
    Database\registerDefaultConnection($db);
    
    @Table("users")
    class User {
        public int $id;
        
        @Column("name")
        public string $userName;
        
        public int $age;
        
        public float $coin;
        
        @Column("create_at")
        public string $createAt;
    }
    
    $data = DB<User>();
    
    echo "=== 基础查询 ===\n";
    $user = $data->where("id = ?", 100)->first();
    dump($user);
    

    除了 array 数组外,还有增强数组

    $list = new List<int>();
    $list->add(1);
    $list->add(2);
    $list->add(3);
    
    // 手动迭代
    $list->rewind();
    while ($list->valid()) {
        echo "索引: " . $list->key() . ", 值: " . $list->current() . "\n";
        $list->next();
    }
    

    KV 方式的泛型类

    $map = new HashMap<string, int>();
    $map->put("apple", 10);
    $map->put("banana", 20);
    $map->put("orange", 30);
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3819 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 10:38 · PVG 18:38 · LAX 03:38 · JFK 06:38
    ♥ Do have faith in what you're doing.