Download the PHP package happyphper/dify without Composer

On this page you can find all versions of the php package happyphper/dify. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dify

Dify PHP SDK

A PHP SDK for Dify API, with support for the Hyperf framework.

中文文档

Requirements

Latest Updates (v1.2.0)

Token Auto-Refresh Feature

Dify PHP SDK now supports token auto-refresh functionality, allowing your application to seamlessly handle authentication token expiration:

These features allow your application to focus on business logic without worrying about the complexity of token management.

Installation

Usage with Hyperf

Publish Configuration

This will create the following files:

Configuration

Add the following to your .env file:

Cache Configuration

Dify PHP SDK supports multiple cache drivers for storing authentication tokens and other information. Currently, the following cache drivers are supported:

You can specify the cache driver and related configuration in the configuration file:

Complete Configuration File Structure

Below is the complete structure of the configuration file with all available options:

Basic Usage

Usage without Hyperf

Workflow Orchestration Chat API

Note: The Workflow Orchestration Chat API is planned for future releases. The following documentation outlines the planned functionality. Stay tuned for updates!

Basic Usage

Conversation Management

Message Feedback

File Upload and Multimodal Support

Audio Processing

Application Information

For more examples, please refer to the examples/workflow_example.php file.

Console API (Requires Login)

Some operations need to be performed through the Dify Console API, which requires login to obtain a token. The SDK provides a dedicated ConsoleClient class to handle these operations.

Note: The Console API is disabled by default. You need to set DIFY_CONSOLE_ENABLE=true in your .env file or console.enable = true in your configuration file to enable it. If you try to use the ConsoleClient when the Console API is disabled, a ConsoleDisabledException will be thrown.

Basic Usage

Token Auto-Refresh

The ConsoleClient now supports automatic token refresh, which handles token expiration seamlessly:

  1. When an access token expires (401 error), the SDK will:

    • Automatically attempt to refresh the token using the refresh token
    • Retry the original request if refresh is successful
    • Re-login if the refresh token is expired or not available
    • Clear tokens and throw an exception if login fails
  2. The token refresh process is intelligent:
    • Only clears the refresh token upon refresh failure
    • Preserves the access token if it's still valid
    • Handles all token management internally

This allows your application to focus on business logic without worrying about token management.

API Reference

Knowledge Base Operations

Document Operations

Segment Operations

Error Handling

The SDK provides comprehensive error handling mechanisms:

Advanced Usage

Handling Large Amounts of Data

When dealing with large amounts of data, it's recommended to use pagination and appropriate error retry mechanisms:

Troubleshooting

Common Issues

  1. Invalid API Key: Ensure your API key is correct and has the required permissions.

  2. Network Connection Issues: Check your network connection and firewall settings.

  3. Request Format Errors: Ensure the request parameters are in the correct format.

Enable Debugging

If you encounter issues, you can implement logging logic to capture request and response information to help debug problems.

Testing

Running Tests

Test Coverage

To generate the test coverage report, run:

This will generate an HTML coverage report in the coverage directory. You can open coverage/index.html in your browser to view detailed coverage information.

Current test coverage:

Complete API Documentation

For complete documentation of the Dify API, please refer to the Dify API Documentation.

License

MIT


All versions of dify with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
psr/log Version ^1.0|^2.0|^3.0
hyperf/guzzle Version ^3.1
ext-fileinfo Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package happyphper/dify contains the following files

Loading the files please wait ...