Tuesday, 27 August 2024

Test PHP codes using Docker container

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

Wednesday, 14 August 2024

PayPal Sandbox

Developer Account, Business Account and Rest APP

  • Business account is linked to develoer account
  • When create a Rest APP, need to choose a business account
  • PayPal merchant id is from the business account
  • client id and secrete is from Rest App

If PayPal merchant id is not matched to client id/secrete, may get the following error when do refund.

'issue' => 'PERMISSION_DENIED',
      'field' => 'capture_id',
      'value' => '7VJ16605X3012345',
      'description' => 'You do not have permission to access or perform operations on this resource.'