css-inline uses components from Mozilla's Servo project and provides
- bindings for Rust, Python, Ruby, JavaScript, Java, and C. The
+ bindings for Rust, Python, Ruby, JavaScript, Java, C, and PHP. The
playground runs the library compiled to WebAssembly in the browser.
Paste HTML with CSS into the text area and click "Inline" to process
the output.
diff --git a/bindings/php/.cargo/config.toml b/bindings/php/.cargo/config.toml
new file mode 100644
index 00000000..d566dec3
--- /dev/null
+++ b/bindings/php/.cargo/config.toml
@@ -0,0 +1,12 @@
+[target.x86_64-unknown-linux-gnu]
+rustflags = ["-C", "link-arg=-Wl,-undefined,dynamic_lookup"]
+
+[target.x86_64-apple-darwin]
+rustflags = ["-C", "link-arg=-Wl,-undefined,dynamic_lookup"]
+
+[target.aarch64-apple-darwin]
+rustflags = ["-C", "link-arg=-Wl,-undefined,dynamic_lookup"]
+
+[target.x86_64-pc-windows-msvc]
+linker = "rust-lld"
+rustflags = ["-C", "link-arg=/FORCE"]
diff --git a/bindings/php/.gitignore b/bindings/php/.gitignore
new file mode 100644
index 00000000..7993a8ef
--- /dev/null
+++ b/bindings/php/.gitignore
@@ -0,0 +1,4 @@
+/vendor/
+/composer.lock
+/.phpunit.cache/
+/.php-cs-fixer.cache
diff --git a/bindings/php/.php-cs-fixer.dist.php b/bindings/php/.php-cs-fixer.dist.php
new file mode 100644
index 00000000..00477833
--- /dev/null
+++ b/bindings/php/.php-cs-fixer.dist.php
@@ -0,0 +1,21 @@
+in(__DIR__ . '/tests')
+ ->in(__DIR__ . '/stubs')
+ ->in(__DIR__ . '/benchmarks')
+ ->name('*.php');
+
+return (new PhpCsFixer\Config())
+ ->setRiskyAllowed(true)
+ ->setRules([
+ '@PER-CS' => true,
+ '@PHP82Migration' => true,
+ 'array_syntax' => ['syntax' => 'short'],
+ 'declare_strict_types' => true,
+ 'no_unused_imports' => true,
+ 'ordered_imports' => ['sort_algorithm' => 'alpha'],
+ 'single_quote' => true,
+ 'trailing_comma_in_multiline' => true,
+ ])
+ ->setFinder($finder);
diff --git a/bindings/php/Cargo.toml b/bindings/php/Cargo.toml
new file mode 100644
index 00000000..e88065fb
--- /dev/null
+++ b/bindings/php/Cargo.toml
@@ -0,0 +1,19 @@
+[package]
+name = "css_inline"
+version = "0.18.0"
+edition = "2021"
+authors = ["Dmitry Dygalo "]
+
+[lib]
+name = "css_inline_php"
+crate-type = ["cdylib"]
+
+[dependencies]
+ext-php-rs = "0.15.2"
+rayon = "1"
+
+[dependencies.css-inline]
+path = "../../css-inline"
+version = "*"
+default-features = false
+features = ["http", "file", "stylesheet-cache"]
diff --git a/bindings/php/README.md b/bindings/php/README.md
new file mode 100644
index 00000000..9e8d86d8
--- /dev/null
+++ b/bindings/php/README.md
@@ -0,0 +1,299 @@
+# css_inline
+
+[](https://github.com/Stranger6667/css-inline/actions/workflows/build.yml)
+[](https://app.codecov.io/github/Stranger6667/css-inline)
+[](https://gitter.im/Stranger6667/css-inline)
+
+`css_inline` is a high-performance library for inlining CSS into HTML 'style' attributes.
+
+This library is designed for scenarios such as preparing HTML emails or embedding HTML into third-party web pages.
+
+For instance, the library transforms HTML like this:
+
+```html
+
+
+
+
+
+
Big Text
+
+
+```
+
+into:
+
+```html
+
+
+
+
Big Text
+
+
+```
+
+- Uses reliable components from Mozilla's Servo project
+- 3-25x faster than alternatives
+- Inlines CSS from `style` and `link` tags
+- Removes `style` and `link` tags
+- Resolves external stylesheets (including local files)
+- Optionally caches external stylesheets
+- Can process multiple documents in parallel
+- Works on Linux and macOS (Windows is not supported)
+- Supports HTML5 & CSS3
+
+## Playground
+
+If you'd like to try `css-inline`, you can check the WebAssembly-powered [playground](https://css-inline.org/) to see the results instantly.
+
+## Installation
+
+`css_inline` is distributed as a PHP extension. You'll need to compile it from source:
+
+```shell
+git clone https://github.com/Stranger6667/css-inline.git
+cd css-inline/bindings/php
+cargo build --release
+```
+
+Then copy the compiled extension to your PHP extensions directory:
+
+```shell
+# Linux
+cp target/release/libcss_inline_php.so $(php-config --extension-dir)/css_inline.so
+
+# macOS
+cp target/release/libcss_inline_php.dylib $(php-config --extension-dir)/css_inline.so
+```
+
+Enable the extension in your `php.ini`:
+
+```ini
+extension=css_inline
+```
+
+Requirements:
+- PHP 8.2 or higher
+- Rust toolchain (for building from source)
+- Linux or macOS (Windows is not supported by the underlying `ext-php-rs` library)
+
+## Usage
+
+```php
+
+
+
+
+
+