Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine

PHP 7: The Important Stuff

40:26

What you'll be learning

This tutorial uses Symfony 3, but all the concepts around PHP 7 are still ?valid.
// composer.json
{
    "require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.3.*", // v3.3.18
        "doctrine/orm": "^2.5", // v2.7.2
        "doctrine/doctrine-bundle": "^1.6", // 1.10.3
        "doctrine/doctrine-cache-bundle": "^1.2", // 1.3.2
        "symfony/swiftmailer-bundle": "^2.3", // v2.5.4
        "symfony/monolog-bundle": "^2.8", // v2.12.1
        "symfony/polyfill-apcu": "^1.0", // v1.3.0
        "sensio/distribution-bundle": "^5.0", // v5.0.19
        "sensio/framework-extra-bundle": "^3.0.2", // v3.0.25
        "incenteev/composer-parameter-handler": "^2.0", // v2.1.2
        "knplabs/knp-markdown-bundle": "^1.4", // 1.5.1
        "doctrine/doctrine-migrations-bundle": "^1.1", // v1.2.1
        "stof/doctrine-extensions-bundle": "^1.2", // v1.2.2
        "composer/package-versions-deprecated": "^1.11" // 1.11.99
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0", // v3.1.4
        "symfony/phpunit-bridge": "^3.0", // v3.2.8
        "nelmio/alice": "^2.1", // v2.3.1
        "doctrine/doctrine-fixtures-bundle": "^2.3", // v2.4.1
        "symfony/web-server-bundle": "3.3.*"
    }
}

PHP 5 is dead! So it's finally time to look at PHP 7 and learn all about the important stuff it brings. We're talking about scalar type declarations, return types, and the spaceship operator! Actually, not that last thing - there is a new spaceship operator (<=>) in PHP 7, but other than having a cool name... it's not really very important. Instead, we'll focus on:

  • Scalar type declarations and return types
  • Nullable types
  • Void types
  • Class constant visibility
  • New error and exception handling

And, PHP7 is fast! So let's get to it!


Your Guides

Andrew Marcinkevičius Ryan Weaver

Buy Access

Join the Conversation?

6
Login or Register to join the conversation
Default user avatar

Cheers guys

1 Reply
Lionel-F Avatar
Lionel-F Avatar Lionel-F | posted 2 years ago

Hi guys, do you plan to do a php 8 tutorial with the upcoming SF6 release (which will support php8 at least) ?

Reply

Hey Lionel F.!

Hmm, I honestly hadn't thought about it much yet, but that's a pretty good idea - a quick PHP 8 bootcamp people could use as they start using Symfony 6. Perhaps also with 8.1 features on top if it (Symfony 6 will only require 8.0, but 8.1 will release nearly the same day).

We'll talk it over with the team - thanks for the suggestion!

1 Reply
Tim-R Avatar

I'd love to see that too :)

Reply
Default user avatar
Default user avatar Micheal | posted 5 years ago

But I want to hear about the spaceship operator. :'( ;)

Reply

Hahaha, maybe it'll make a quick cameo appearance ;)

3 Reply
Cat in space

"Houston: no signs of life"
Start the conversation!

userVoice