Download the PHP package sitefinitysteve/php-diff-text without Composer

On this page you can find all versions of the php package sitefinitysteve/php-diff-text. 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 php-diff-text

php-diff-text

PHP library to generate HTML diff output with multiple diff strategies. Zero external dependencies.

This is a PHP variant of vue-diff-text, a Vue 3 plugin for displaying text and HTML differences. Same diff strategies, same HTML output, same CSS classes — just in PHP.

Author: Steve McNiven-Scott

Installation

That's it — Composer's autoloader handles the rest. No service providers, no config files.

Usage

Each diff class takes old and new text and returns HTML with .diff-added and .diff-removed spans.

Quick start (any PHP project)

Or use the individual classes directly:

Laravel Blade example

In your controller:

In your Blade template:

Tip: Copy vendor/sitefinitysteve/php-diff-text/css/style.css into public/vendor/php-diff-text/style.css, or add it to your Vite/Mix pipeline.

Output:

Available Diff Classes

Class Description
DiffChars Character-level diff
DiffWords Word-level diff (ignores whitespace)
DiffWordsWithSpace Word-level diff (whitespace-aware)
DiffLines Line-level diff
DiffSentences Sentence-level diff
DiffHtml HTML-aware diff with optional similarity threshold

All methods are static — no instantiation needed.

DiffText Facade

The DiffText class is the recommended entry point:

Options

All text diff classes accept an options array:

HTML Diff with Similarity Threshold

DiffHtml supports a similarity threshold (0-1). When the texts are less similar than the threshold, it renders a "full replacement" instead of a granular diff:

Similarity Utility

Compute text similarity directly:

Styling

Include the bundled CSS for default diff styling:

Or copy it into your asset pipeline. Customize with CSS variables:

Testing

Publishing to Packagist

First-time setup

  1. Create a GitHub repository:

  2. Register on Packagist:

    • Log in with your GitHub account
    • Click "Submit" and enter the GitHub repo URL
    • Packagist will auto-detect the composer.json
  3. Set up auto-updating (recommended):
    • On Packagist, go to your package settings and grab the API token
    • On GitHub, go to repo Settings > Webhooks > Add webhook
    • Payload URL: https://packagist.org/api/github?username=sitefinitysteve
    • Content type: application/json
    • Secret: your Packagist API token
    • Events: "Just the push event"

Releasing a new version

Tag a release and push:

Or use GitHub Releases:

Packagist picks up the new tag automatically via the webhook.

GitHub Actions (optional auto-test on release)

Create .github/workflows/tests.yml:

License

MIT


Made with ❤️ by sitefinitysteve


All versions of php-diff-text with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
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 sitefinitysteve/php-diff-text contains the following files

Loading the files please wait ...