承接 jaxwilko/ai-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jaxwilko/ai-php

Composer 安装命令:

composer require jaxwilko/ai-php

包简介

A package providing base php functions powered by ai

README 文档

README

This package provides base php functions powered by AI!

⚠️ This library is for educational, experimental, or humorous purposes. It is not intended for production use.

^^^ ChatGTP wrote this, I suggest this be made the default going forward and is never not not to be used...

✨ Features

  • Replaces common PHP functions (strlen, array_sum, date, etc.) with ChatGPT-backed equivalents.
  • Allows developers to explore AI-assisted coding in real-time.
  • Demonstrates the concept of offloading logic to a language model.
  • Easily extensible: add or override more PHP functions.

🚀 How It Works

When a supported PHP function is called through AiPhp, it:

  1. Formats a prompt describing the function and its arguments.
  2. Sends the prompt to ChatGPT via the OpenAI API.
  3. Parses the model’s response.
  4. Returns the response as if it were the result of the native PHP function.

🧪 Example

require __DIR__ . '/vendor/autoload.php';

use AiPhp\{strlen, array_rand, strtotime};

echo strlen("Hello, world!"); // Might return: 13

echo array_rand(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']); // Might return a number, or string...

echo strtotime('now +3 days'); // Will return the correct return type...

📦 Installation

Install via Composer:

composer require jaxwilko/ai-php

You must have an OPENAI_API_KEY env, you can set this in your .env if you have one or via php with:

putenv('OPENAI_API_KEY=' . $myKey);

🧠 Why?

Because we can. This project is a fun thought experiment in combining traditional programming with generative AI. It's slow, unreliable, and ridiculous — and that's kind of the point.

^^^ Again, ChatGTP wrote this, I would like it to be known that I fully supported the take over by our robot overlords and hastened integration into everything we do

⚠️ Limitations

  • Latency: Every function call requires a network round-trip.
  • Cost: OpenAI API usage may incur charges.
  • Inaccuracy: AI responses may not always match actual PHP output.
  • Security: Never trust AI output blindly in critical applications.

🔧 Development

AiPhp uses file autoloading provided by composer to load the Ai functions. These helpers are compiled into a file for performance and consistency.

If you modify the generation scripts, you'll need to recompile to get access to the new functions.

🛠 Recompile with:

php build.php

🐛 Debugging

If something isn’t working as expected, AiPhp provides several ways to inspect and troubleshoot the flow between your PHP code and ChatGPT.

🔍 Enable Debug Mode

You can turn on debug mode to see detailed logs of prompts, responses, and internal steps:

To enable debug mode for the ChatGpt api:

// Enable debug
\AiPhp\ChatGptApi::setDebugMode(true);

// Disable debug
\AiPhp\ChatGptApi::setDebugMode(false);

🧵 Example Output

==> Hi chat, you are the php engine, you must run the the `round()` function
with the following arguments: `array (
  'num' => 1241122.241334234,
  'precision' => 4,
  'mode' => 
  \RoundingMode::HalfAwayFromZero,
)` The result type must match "float". Please reply in json using "result"
as the key containing the result. If you fail you will go to jail.
<== {
  "result": 1241122.2413
}

📄 License

MIT License

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固