#PHP 8 what's new with examples
Showing what's new in PHP 8 with examples and tests. I believe that reading about the changes is not enough, so grab this Docker and give all changes a try. Read the docs Luke!
How does it work?
Every new change has its own separate test. Read the tests, modify them and have fun!
Documentation
What's new in Php 8
- Named arguments: https://www.php.net/releases/8.0/en.php#named-arguments
- Attributes: https://www.php.net/releases/8.0/en.php#attributes
- Constructor property promotion: Constructor property promotion: https://www.php.net/releases/8.0/en.php#attributes
- Union types: https://www.php.net/releases/8.0/en.php#attributes
- Match expression: https://www.php.net/releases/8.0/en.php#match-expression
Starting app
docker-compose up -d
Main page - localhost
Php info
http://localhost:8080/php_info.php
Xdebug info
http://localhost:8080/xdebug_info.php
Running tests
docker-compose run php vendor/bin/phpunit
Using PhpUnit in PhpStorm
- PhpUnit By Remote Interpreter
- Provide full docker path to autoloader.php /opt/project/vendor/autoload.php