1. Products
  2.   HTML
  3.   PHP
  4.   Aspose.HTML Cloud SDK for PHP

Aspose.HTML Cloud SDK for PHP


PHP HTML REST SDK to Render, Manipulate & Export HTML Files

A Powerful PHP SDK for working with HTML Documents in the Cloud. It allows to Create, Edit, Parse & Convert HTML Files to JSON, PDF, Images, MHTML, SVG, XPS, DOCX, EPUB & more.

In today's digital age, HTML manipulation has become an essential part of web development, content generation, and data extraction. . Aspose.HTML Cloud SDK for PHP offers an innovative solution for developers to effortlessly manipulate HTML documents in a cloud-based environment. With HTML rendering, software developers can generate documents in multiple formats, making it easier to display content across various platforms and devices. This SDK serves as a bridge between your PHP application and the cloud-based Aspose.HTML service, bringing forth a range of functionalities that can greatly enhance your HTML processing workflow.

Aspose.HTML Cloud SDK for PHP is a powerful and versatile cloud-based library that allows developers to perform a wide range of HTML-related operations, such as parsing HTML documents, extracting information, validating HTML documents, HTML templating support, optimizing HTML content, converting to different formats, and rendering HTML pages to various file types like PDF, XPS, and images. The SDK provides seamless integration of Aspose.HTML Cloud API with PHP applications, enabling developers to leverage its functionalities without worrying about complex server setups or maintenance.

Aspose.HTML Cloud SDK for PHP ensures data security during HTML processing by using secure communication protocols and encryption methods. This safeguards sensitive information and ensures compliance with industry standards. Its robust features and functionalities enable developers to streamline HTML processing tasks, ensuring seamless data extraction, document generation, and cross-platform content rendering. Whether you're a web developer, content creator, or data analyst, integrating this powerful library into your PHP applications will undoubtedly boost productivity and enhance your HTML manipulation capabilities.

Previous Next

Getting Started with Aspose.HTML Cloud SDK for PHP

The recommend way to install Aspose.HTML Cloud SDK for PHP via Composer. You can easily use the API directly in your Maven Projects with simple configurations.

Install Aspose.HTML Cloud SDK for PHP via Composer

  "repositories": [
      "type": "git",
      "url": "https://github.com/aspose-html-cloud/aspose-html-cloud-php.git"
  "require": {
    "aspose/aspose-html-cloud-php": "dev-master"

You can download the library directly from Aspose.HTML Cloud SDK for PHP product page

Parse & Manipulate HTML Files in PHP Apps

Aspose.HTML Cloud SDK for PHP is a very easy to use library that allows software developers to load and parse HTML documents with just a couple of lines of PHP code. The SDK offers the capability to parse HTML documents and extract crucial information, such as tags, elements, and attributes. This feature proves particularly useful for web scraping, content extraction, manipulate the structure of HTML content, facilitating dynamic and customized web pages as well as data analysis tasks.

Parsing and Manipulating HTML Files via PHP API

require 'vendor/autoload.php';

use Aspose\HTML\Cloud\Api\HTMLApi;
use Aspose\HTML\Cloud\Configuration;

// Set up API credentials
$config = new Configuration();

// Initialize HTML API
$api = new HTMLApi(null, $config);

// HTML file path
$htmlFilePath = 'path/to/your/input.html';

try {
    // Parse HTML file
    $parsedDocumentResponse = $api->getHtmlDocumentByUrl($htmlFilePath);

    // Extract HTML content
    $htmlContent = $parsedDocumentResponse->getDocument()->getContents();

    // Perform your desired manipulation on $htmlContent here
    // For example, let's add a header to the HTML content
    $header = '

Welcome to My Website

'; $manipulatedHtmlContent = $header . $htmlContent; // Save the manipulated HTML content to a new file $outputFilePath = 'path/to/your/output.html'; file_put_contents($outputFilePath, $manipulatedHtmlContent); echo 'HTML file parsed and manipulated successfully!'; } catch (\Exception $e) { echo 'Error: ' . $e->getMessage(); }

HTML File Conversion via PHP API

Transforming HTML content into PDF documents is a common requirement, especially when generating reports, invoices, or printable content. The Aspose.HTML Cloud SDK for PHP offers a robust conversion feature that effortlessly converts HTML documents to various other supported file formats. The SDK enables seamless conversion between different formats, such as HTML to MHTML, EPUB to HTML, JSON, Images and many more. This flexibility facilitates smooth data exchange and content migration between various systems. The following example shows how to convert a website to a local File using PHP code.

How to Convert the Website to a Local File via PHP REST API?

require_once(__DIR__ . '/vendor/autoload.php');

$configuration = array(
    "basePath" => "https://api.aspose.cloud/v4.0",
    "authPath" => "https://api.aspose.cloud/connect/token",
    "defaultUserAgent" => "Webkit"

$api_html = new HtmlApi($configuration);

$src = 'https://stallman.org/articles/anonymous-payments-thru-phones.html';
$dst = 'c:/test.pdf';
$options = null;

try {
    $result = $api_html->convertUrlToLocal($src, $dst, $options);
} catch (Exception $e) {
    echo 'Exception when calling $api_html->convertUrlToLocal: ', $e->getMessage(), PHP_EOL;

HTML Templating Support via PHP API

Building and maintaining consistent layouts across a web application can be challenging. Software developers can create HTML templates dynamically, allowing for efficient content generation and customization. Aspose.HTML Cloud SDK for PHP makes it easy for software developers to create reusable templates and efficiently apply them to different parts of their application. This feature is beneficial when building dynamic websites, newsletters, or personalized email campaigns. Moreover, it provides tools to dynamically adjust and optimize HTML content for responsive layouts.

HTML Rendering & Validation Support

With Aspose.HTML Cloud SDK for PHP, users can render HTML pages to various formats, including PDF, XPS, and images. This functionality is handy when users need to generate high-quality reports, invoices, or dynamic content that can be displayed across multiple platforms. Moreover, ensuring the validity of HTML documents is crucial for consistent rendering across various browsers and devices. The PHP SDK includes validation capabilities that allow software developers to validate HTML against industry standards and best practices.