codegyan/php-compiler-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

codegyan/php-compiler-sdk

最新稳定版本:v1.0.2

Composer 安装命令:

composer require codegyan/php-compiler-sdk

包简介

SDK for interacting with Codegyan PHP Compiler API

README 文档

README

License PHP Packagist Packagist

This SDK provides a convenient way to interact with the Codegyan PHP Compiler API, allowing you to compile PHP code programmatically.

Installation

You can install the SDK via Composer. Run the following command:

composer require codegyan/php-compiler-sdk

Usages

Before using the SDK, you need to obtain an API key and client ID from Codegyan. Follow these steps to get your API credentials:

  1. Sign Up/Login: If you don't have an account, sign up for a Codegyan account. If you already have an account, log in to your dashboard.

  2. Get Credentials: Once logged in, navigate to the Developer Console or API settings in your account dashboard. Here, you will find your API key and client ID. Copy these credentials and use them when initializing the SDK client in your code.

Here's an example of how to initialize the SDK client with your API key and client ID:

<?php

require_once 'vendor/autoload.php';

use Codegyan\Compiler\Client;

// Replace 'YOUR_API_KEY' and 'YOUR_CLIENT_ID' with your actual API key and client ID
$apiKey = 'YOUR_API_KEY';
$clientId = 'YOUR_CLIENT_ID';

// Initialize the SDK client
$compiler = new Client($apiKey, $clientId);

// PHP code to be compiled
$code = '<?php echo "Hello, world!"; ?>';

try {
    // Compile PHP code
    $compiledCode = $compiler->compilePHPCode($code);

    // Decode the JSON string to an associative array
    $compiledData = json_decode($compiledCode, true);

    // Check if the compiled code status is equal to 15
    if ($compiledData['status'] == 15) {
        echo "Compiled code: " . $compiledData['output'];
    } else {
       echo $compiledCode;
    }
} catch (Exception $e) {
    echo 'Error: ' . $e->getMessage();
}

?>

Features

  • Compile PHP Code: The SDK allows you to compile PHP code using the Codegyan PHP Compiler API.
  • Error Handling: Proper error handling is implemented to catch and handle exceptions thrown during API requests.
  • Customization: You can customize the SDK by passing different parameters to the constructor or by modifying the code to fit your specific requirements.

Testing

The SDK includes PHPUnit tests to ensure its functionality is working as expected. You can run the tests using the following command:

vendor/bin/phpunit

Contributing

Contributions are welcome! Feel free to submit bug reports, feature requests, or pull requests to help improve this SDK.

License

This Codegyan SDK is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-08