DEV Community

Jitendra
Jitendra

Posted on

13 7

Hands on with PHP7.4

As most of us already know, PHP7.4 became production ready few days back. It comes with some cool features like:

  • Short Arrow Functions
  • Spread Operator for Arrays
  • Typed Properties
  • Opcache Preloading

... and much more! We can't thank the team behind PHP enough!

If you are a PHP developer or PHP enthusiast you must be excited already to get hands on with PHP7.4.

If you want to give it a try with ease - the docker way, then I have created a docker image with not just PHP7.4 but tons of common and useful PHP extensions. Check it out.

TLDR: docker pull adhocore/phpfpm:7.4

GitHub logo adhocore / docker-phpfpm

Docker PHP FPM on alpine 3.15 with PHP7.4.32 with 87 extensions and PHP8.0.24/PHP8.1.11 with 85 useful extensions (you can disable not necessary ones easily)

docker-phpfpm

Docker build Donate 15 Donate 25 Donate 50 Tweet

Docker PHP FPM with lean alpine base. The download size is just about ~150MB.

It contains PHP8.1.11 and PHP8.0.24 with plenty of common and useful extensions.

You can also continue using adhocore/phpfpm:7.4 for PHP7.4.30.

If you are looking for a complete local development stack then check adhocore/lemp.

It comes prepackaged with composer - both v1 and v2 Use composer2 command for v2 and composer for v1.

Usage

To pull latest image:

docker pull adhocore/phpfpm:8.0

# or for alpine 3.13
docker pull adhocore/phpfpm:8.0-alp3.13

# or for php 7.4
docker pull adhocore/phpfpm:7.4

# or for php 7.4 on alpine 3.13
docker pull adhocore/phpfpm:7.4-alp3.13
Enter fullscreen mode Exit fullscreen mode

To use in docker-compose

# ./docker-compose.yml
version: '3'

services:
  phpfpm:
    image: adhocore/phpfpm:8.0
    container_name: phpfpm
    volumes:
      - ./path/to/your/app:/var/www/html
      # Here you can also volume php ini settings
      # - /path/to/zz-overrides:/usr/local/etc/php/conf.d/zz-overrides.ini
    ports:
      - 9000:9000
    environment:
      # ...
Enter fullscreen mode Exit fullscreen mode

Composer

Latest…

If you want a full docker based LEMP stack with PHP7.4, then I have got you covered as well.

TLDR: Run docker run -p 8080:80 -v $(pwd):/var/www/html --name lemp -d adhocore/lemp:7.4 then visit localhost:8080. There you have dockerized LEMP stack with PHP7.4.

GitHub logo adhocore / docker-lemp

A single container LEMP complete fullstack with latest release of PHP7.4.30, 8.0.24 & 8.1.11 and MySQL, nginx, PostgreSQL, phalcon, swoole, mailcatcher, beanstalkd, elasticsearch, memcached, redis, adminer and all you ever need; on top alpine3.15

docker-lemp

Docker build Donate 15 Donate 25 Donate 50 Tweet

Do not use this LEMP in Production For production, use adhocore/phpfpm then compose a stack using individual nginx, redis, mysql etc images.

adhocore/lemp is a minimal single container LEMP full stack for local development.

If you want to use PHP7.4 on LEMP stack then head over to adhocore/lemp:7.4.

It is quick jumpstart for onboarding you into docker based development The download size is just about ~360MB which is tiny considering how much tools and stuffs it contains.

The docker container adhocore/lemp is composed of:

Name Version Port
adminer 4.8.1 80
alpine 3.15 -
beanstalkd 1.11 11300
elasticsearch* 6.4.3 9200,9300
mailcatcher 0.7.1 88
memcached 1.6.6 11211
MySQL** 5.7 3306
nginx 1.18.0 80
phalcon 4.0.0 -
PHP8.1 8.1.11 9000
PHP8.0 8.0.24 9000
PHP7.4 7.4.30 9000
PostgreSQL 12.6 5432
rabbitmq 3.8.* 5672
redis 5.0.11 6379
swoole 4.5.9 -

*: Latest versions of alpine (3.13+) seems to…

Oh and both the images are built on top alpine base so should be slimmer.

Further reading

PHP7.4 Changelog
PHP7.4 Benchmark

Top comments (0)

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay