Skip to content

⚡️ Codegyan is a supercharged community-maintained PHP API client that allows you to interact with Codegyan API.

License

Notifications You must be signed in to change notification settings

Codegyan-LLC/php-compiler-sdk

Repository files navigation

Codegyan PHP Compiler SDK

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.

About

⚡️ Codegyan is a supercharged community-maintained PHP API client that allows you to interact with Codegyan API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages