Building the following Dockerfile will give you the latest version of my ext/dom HTML5 branch:
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt update
RUN apt install -y binutils gcc re2c flex bison libxml2-dev libsqlite3-dev vim git autoconf pkg-config make libonig-dev
WORKDIR /
ADD https://api.github.com/repos/nielsdos/php-src/git/refs/heads/dom-bridge-lexbor version.json
RUN git clone -b dom-bridge-lexbor https://github.com/nielsdos/php-src.git
WORKDIR /php-src
RUN ./buildconf --force
RUN apt install -y libreadline-dev libssl-dev
RUN ./configure --enable-mbstring --with-readline --with-openssl
RUN make -j4
RUN make install
ENTRYPOINT ["/bin/bash"]
Save it as "Dockerfile" in an empty directory, enter that directory and execute the following command to build it:
$ docker build -t extdomhtml5 .
After the building is done, you can enter the container using:
$ docker run --rm -it extdomhtml5
You can use the php -a
command to try it out.
Or you can create a PHP script to try it out, or share a directory with your host.
Examples:
<?php
$dom = DOM\HTMLDocument::createFromString("<p>foo</p>");
// Or files
$dom = DOM\HTMLDocument::createFromFile("myfile.html");
// Any method you're used to will work fine with documents parsed using the HTML5 parser.
echo $dom->saveHTML();