PHP installed in your local machine is PHP 7. You want to test if your codes work in PHP 8.3. You can use Docker container to do the testing.
#Dockerfile
FROM php:8.3.11RC2-zts-alpine3.20
RUN apk update
RUN apk add php83-dom php83-tokenizer php83-fileinfo php83-simplexml \
apache2 php83 php83-apache2 php83-ctype php83-openssl \
php83-curl php83-pecl-apcu php83-opcache php83-bcmath php83-xml \
php83-intl php83-iconv php83-mbstring php83-session php83-common \
bash util-linux-misc
RUN apk upgrade
COPY ./ /var/src
<?
//test.php
echo "Hello world", "\n";
Step one: put Dockerfile into the same directory where test.php (your php codes) is in.
Step two: Build image, run container and do testing.
#build docker image
docker build --no-cache -t my-test .
#run docker image and go inside container
docker run -it my-test bash
# go to working directory and run the script
cd /var/src
php test.php
No comments:
Post a Comment