Coder Social home page Coder Social logo

php-81-composite-demo-20211026's Introduction

PHP 8.1 Demo Code

This code demonstrates various PHP 8.0 and 8.1 features in a realistic, functional (but incomplete) codebase. The code is part of some DNS validation logic.

This code came from a code along session in the October 2021 Arizona PHP User Group meetup, and was inspired by some refactoring work I was doing at my day job.

Feature Sightings

  • Enums
  • Throw exceptions as an expression
  • Constructor property promotion
  • Readonly properties
  • Union types
  • static return type
  • First class callables
  • new in initializers
  • match expressions
  • Trailing commas in parameter lists
  • catch exceptions without a variable

Running the Code

Requirements

  • Docker
  • PHP
  • Composer

Instructions

  1. Uncomment lines 10 and 11 in index.php.
    • This is because you are running Composer locally, and not in the container, so the current version of Composer you have will not include the enums in with the autoloader.
  2. Run composer run shell to download the php 8.1 image and boot up a docker container for it with a shell.
  3. Run php index.php within the container's shell to execute this file.
  4. Run exit to exit and shutdown the container.

Resources

php-81-composite-demo-20211026's People

Contributors

jeremeamia avatar

Stargazers

Roman Pronskiy avatar  avatar

Watchers

Joshua Eichorn avatar  avatar Noah Spirakus avatar Tim Klever avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.