5 Reasons to Use PHP 8: New Syntax Features

Поделиться
HTML-код
  • Опубликовано: 28 авг 2024
  • Are you still on PHP 7.x? Let me convince you to upgrade, maybe you will like those syntax "treats" from PHP 8.0.
    PHP Version Statistics: packagist.org/...
    PHP Official Supported versions: www.php.net/su...
    PHP 8 Examples from the video:
    - Match example: / 1451905555182850048
    - Null safe operator: / 1452598536101580817
    - Null safe operator example 2: php.watch/vers...
    - Named parameters: / 1450781816957374468
    - Constructor property promotion: / 1334077673740656651
    - Union types: stitcher.io/bl...
    What’s New in Laravel 9: A Deep Dive Into the Upcoming Major Release kinsta.com/blo...
    - - - - -
    Support the channel by checking out our products:
    - Enroll in my Laravel courses: laraveldaily.t...
    - Try our Laravel QuickAdminPanel: bit.ly/quickad...
    - Purchase my Livewire Kit: livewirekit.com
    - View Laravel Code Examples: laravelexample...
    - Subscribe to my weekly newsletter: bit.ly/laravel-...

Комментарии • 93

  • @Stoney_Eagle
    @Stoney_Eagle 2 года назад +35

    The null safe operator is the reason I made the switch right away. I love it in Javascript too 😉

    • @MustafaBirsoz
      @MustafaBirsoz 2 года назад +2

      same here

    • @parlor3115
      @parlor3115 2 года назад +4

      Constructor property promotion, named arguments and attributes did it for me.

    • @christopherokonkwo
      @christopherokonkwo 2 года назад

      Same here

    • @agusx244
      @agusx244 2 года назад +1

      and named arguments is my other reason.

  • @marcusgaius
    @marcusgaius 2 года назад +7

    Null safe, promoted properties, named arguments, mixed/union type, all the goodies!
    Wrote it before even watching, just from what I use every day

  • @ericbitim
    @ericbitim 2 года назад +3

    Already on PHP 8, and I love it so much.

  • @akarimdad1995
    @akarimdad1995 2 года назад +2

    man i love your videos no unnecessary jokes or comment straight to the point

    • @LaravelDaily
      @LaravelDaily  2 года назад +3

      I actually debate with myself to add some jokes or some personal notes to make videos less serious and more "personal", but maybe it's not the right audience for such change :)

    • @akarimdad1995
      @akarimdad1995 2 года назад

      @@LaravelDaily sir I am trying to develop a laravel application where each users role have a different dashboard
      for example application that contains multiple store, i as admin can see all stores and their data
      but if someone log-in as a store manager could only see his store data
      so my question is what are the things i should learn if you have course for this specific task please do let me know please keep that in mind I'm new to laravel i have less than a year of experience

    • @LaravelDaily
      @LaravelDaily  2 года назад +1

      Roles: ruclips.net/video/kZOgH3-0Bko/видео.html
      Tenancy videos: ruclips.net/user/LaravelDailysearch?query=tenancy

    • @akarimdad1995
      @akarimdad1995 2 года назад +1

      @@LaravelDaily you just made my day thank you

  • @glurp1er
    @glurp1er Год назад +2

    Named arguments sound pretty useful, I often used arrays as arguments for the same reason.

  • @GamePlayByFaks
    @GamePlayByFaks 2 года назад +3

    Personally using 8 but due (my) to packages in open source, I still have to support from 7.4, also been planning to upgrade to 8.1 when the time comes.

  • @celebritydev1
    @celebritydev1 2 года назад +1

    Nice. Thanks for the update. match would be a time saver!

  • @coltonwilliams1565
    @coltonwilliams1565 10 месяцев назад

    the null safe operator by itself is worth upgrading

  • @MonethiTebohoArthurnacious
    @MonethiTebohoArthurnacious 2 года назад +3

    I skipped to PHP 8 after release and just learned new features as I went by, I'm using laragon and recently switched to 8.1(R C 5) after seeing a tweet by Tailor. I have done so many projects in php 8 that I automatically write in PHP 8 syntax.

  • @gerard02700
    @gerard02700 2 года назад

    i switched to mern stack since one year, this brings me years of memories with php

  • @imqqmi
    @imqqmi 2 года назад +1

    I've migrated a big application from 7.3 to 7.4, and taken into account the changes to 8.0 as well, wasn't that many. I used phpcompatibility and phpstorm inspect to find all the possible issues and fixed them. Didn't take me more than a couple of days. I've got pretty good coverage with phpunit so getting a stable release was no big deal. The added features is great!
    Note that the adoption rate may also be inhibited by red hat enterprise, since you need to upgrade the os in order to use newer versions of php with their extnended support.

    • @jamesrbrindle
      @jamesrbrindle Год назад +1

      Code coverage. I wish! I work at the really sharp end of the stick. Unit testing is not in the vocabulary of the company I work for under the time is money doctrine. Yet we spend more time fixing things. They don’t value the time required.

    • @imqqmi
      @imqqmi Год назад +1

      @@jamesrbrindle It's often the shortsightedness of management. They don't acknowledge that in order to be in control and ahead of the competition you need to build on a solid foundation and use the modern ways of working. If they don't value this, soon they will be out of business, and if they have the luxury of being the monopoly, a toxic working env may be prevalent. I see this all the time from mid sized to global companies.
      They could fire half the current team if you work efficiently and boost profits 10x, but 2hat do I know 😉

  • @baadrqaaba9529
    @baadrqaaba9529 2 года назад +1

    As soon as php8 came out , i used it right away .

  • @BsiennKhan
    @BsiennKhan 2 года назад +5

    PHP 8 is recent addition, and big projects takes years to build up. Live servers are provisioned with the stack at the project started with, after a while many more projects gets added to the same server. It's not that easy to shift language per project on production as much of a hassle. Dockerizing is not always the luxury.

    • @LaravelDaily
      @LaravelDaily  2 года назад +1

      Yes I realize that upgrading to PHP 8 is a server upgrade issue which is DevOps problem, and not all server setup is flexible. In the past we just created new servers with Forge and moved there instead of upgrading the current one.

    • @latlov
      @latlov 2 года назад

      @@LaravelDaily Laradock doesn't support the PHP latest release right away ...

    • @jamesrbrindle
      @jamesrbrindle Год назад

      This is my exact problem. I still have to maintain a legacy codebase on the same cluster which uses 5 so i’m stuck at Laravel5.4. The company does not have the resources to migrate 30 or more projects as we know the shift to PHP7 will be brutal on time. a lot of pass by reference to rewrite.

  • @sergiuprt
    @sergiuprt 2 года назад +1

    wow! match so far is the greatest.

  • @nullv01d
    @nullv01d 2 года назад +4

    I still use 7.4 on most of my projects. Has a special place in my heart somehow. 😅

  • @levdau
    @levdau 2 года назад +1

    Отличный обзор, спасибо!

  • @alexaverkiyev9099
    @alexaverkiyev9099 2 года назад +7

    Using PHP 8 since it was released. Just too much difference between 7.* and 8.0, you also didn't mention performance which is much better comparing to 7.4

  • @eugenstakhursky9604
    @eugenstakhursky9604 2 года назад

    Yes, I still use php 7, but thank you for this video.

  • @PriyankPatelDroid
    @PriyankPatelDroid 2 года назад

    Thanks for explaining!

  • @InfiraGen
    @InfiraGen 2 года назад +1

    The ice breaker for me was match, it’s awesome

    • @plan0go
      @plan0go Год назад

      looks a bit like switch

  • @CerberusApg
    @CerberusApg 2 года назад +1

    since January 2021 using PHP8 for new projects

  • @chrislanejones
    @chrislanejones 2 года назад

    Nice, this is great!

  • @Andris_Briedis
    @Andris_Briedis 2 года назад +4

    I don't see anything like that due to the need to upgrade to version 8. For me, the only relevant argument would be speed, as it was switching from 5 to 7. 8 performance has improved compared to version 7?
    1. "match" - strongly non-intuitive. I try not to write such code.
    2. "null save operator" - maybe. But again. Nothing could be done in the previous version.
    3. "Named argument" - yes this is good. But again. This could be done with an object or array as a single argument for which values are checked. But yes. This would be helpful.
    4. "Constructor property promotion" - a matter of taste. Once you get used to it, it will be ok. But this is not an argument for changing the version.
    5. "Union types" - Again. Good. But that's not what changes the game.
    p.s. Of course we will have to upgrade to version 8. ;)

  • @dmitxd
    @dmitxd 2 года назад +1

    Already switched to php8 but lake of knowledge about it.

  • @TristanBailey
    @TristanBailey 2 года назад +2

    I like some of the new syntax. Setting up objects with types defined by classes should be nice. I’ve not tried it yet.
    One issue I’ve not got my head around yet is how much time and how often to put into updates that are not for security each year. It is an extra cost for clients but allows moving forward faster but clients are not yet used to having to keep upgrades at many levels of stack without benifit to them that they can see in an app. Any thoughts on selling that and upgrade cycles?

    • @LaravelDaily
      @LaravelDaily  2 года назад +4

      Don't sell that as a separate service, include it in the price of work, or rephrase as a Maintenance task or something like that.

  • @Vincent-on3tl
    @Vincent-on3tl 2 года назад +1

    Finally

  • @llBestBoyll
    @llBestBoyll 2 года назад

    php 8 is awesome

  • @newsall3049
    @newsall3049 2 года назад +1

    thanks we going move php 8+

  • @Warara11
    @Warara11 5 месяцев назад

    I tryed migrate from 7.4 to 8.2 and the user's sessions come up with an issue. The APP simply stop to RW the user's sessions files wich its path is set on .ini file

  • @potaetoupotautoe7939
    @potaetoupotautoe7939 4 месяца назад

    looking up syntax is a pain
    what is the best way to know what they do ?

  • @almostdead009
    @almostdead009 2 года назад +1

    our web app still on php 5.4

  • @GergelyCsermely
    @GergelyCsermely 2 года назад

    Thanks

  • @jamesrbrindle
    @jamesrbrindle Год назад

    I’m stuck with PHP5.4 (therefore Laravel 5.4) due to legacy systems - the company won’t put resources into bringing this up to date and running a mixed environment goes really badly. I don’t see me adopting PHP 8 or even 7 anytime soon which sucks.

  • @Flankymanga
    @Flankymanga 2 года назад

    I do now want to use PHP 8 till 8.1 is out

  • @juve1911
    @juve1911 2 года назад

    could you provide us with examples of using exceptions via php 8 through laravel ? such as using arrow functions/null coalescing operator

  • @raimonds.L
    @raimonds.L 2 года назад

    ?-> is kind of similar to ??, but with ?? you can control the output, e.g. ?? "-"

  • @margop3567
    @margop3567 2 года назад +1

    I would not upgrade and can not upgrade because on live environments upgrades are not so seemles and easy. Anything can break. Also do not forget that if you use some old library that has not been upgraded to match latest laravel or php then it might stop working and cause you more problems that require too much work.

    • @PathOfDamn
      @PathOfDamn 2 года назад

      Unit tests to ensure that it works would be the best for your case- you can hold off the upgrade until all of it passes. No uncertainties at all.

    • @LaravelDaily
      @LaravelDaily  2 года назад

      Yes I realize it's not easy on some projects, and it requires server devops work as well.
      But often it's worth the effort, especially if you think of the project in the long term.

    • @margop3567
      @margop3567 2 года назад

      @@PathOfDamn if you have elasticsearch 6 then you can not upgrade to laravel 8 because there is no library to support eloquent. PHP is usually backward compatible and this is okay to upgrade. Otherwise I would suggest to upgrade to latest if possible but think always on live services that there is ecosystem that can break and you need to start fixing it or there is some other major issue that is not fixable by you especially when you use third-party libraries etc.

  • @ParsclickTV
    @ParsclickTV 6 месяцев назад

    @freek is amazing hes very good

  • @joaolenon8264
    @joaolenon8264 2 года назад

    Hello, nice video by the way. Can you explain how did you get that tool windows like VSCode in your PhpStorm Idea ? I cant find it anywhere...

    • @LaravelDaily
      @LaravelDaily  2 года назад +1

      What tool windows you mean exactly? I didn't configure much in PhpStorm, it's almost default.

    • @joaolenon8264
      @joaolenon8264 2 года назад

      @@LaravelDaily In your Idea, the tools of tool window like project, commit, pull requests, structure etc, are all just icons without the name written. You can press ⌘ + 1, ⌘ + 2, etc to open this tools, Or Alt + 1 I don't remember in Mac.

    • @LaravelDaily
      @LaravelDaily  2 года назад

      Well yes, I just use Cmd + 1 and others to open/close them.

  • @AdlenLucas
    @AdlenLucas 2 года назад

    You could make a video about the version migration problems that we could face from 7.4 to 8.0.

    • @LaravelDaily
      @LaravelDaily  2 года назад

      It's very individual, I can't debug problems which I haven't encountered myself

  • @samiullah0011
    @samiullah0011 2 года назад

    kindly explain constructor promotion property.

  • @jimishukurow2286
    @jimishukurow2286 2 года назад

    Is there anything to convert full html and css file (with display:flex) to pdf , in php 8 or in laravel?

  • @hungnguyenthanh8189
    @hungnguyenthanh8189 2 года назад

    Thank you so much. Sorry I want to ask you another topic question. I have a problem with counting or getting with one million records with multiple tables. Could you give me an answer? Please!!!

    • @LaravelDaily
      @LaravelDaily  2 года назад

      I can give you an answer only if you share the exact code and I could reproduce it on my computer and provide the answer

  • @oleksandrkhrashchevskyi5265
    @oleksandrkhrashchevskyi5265 Год назад

    I upgraded my project from 7.4 to 8.2 and speed increased. According to Google speed, all estimates are higher than 90+ in mobile and pc version. By the way there are js animation such as fade, counter, sound animation and many....
    On php 7.4 targets have value 80,90,90,90
    On php 8.2 94,99,99,99

  • @AtentoCC
    @AtentoCC 2 года назад

    Could you make a video about the problem you see on classes with many properties and constructors with many variables settings? How would you work around this situation? Thank you.

    • @LaravelDaily
      @LaravelDaily  2 года назад

      If you give me a code example, I may try to work with it and improve it

    • @krepver
      @krepver 2 года назад

      IMHO in most cases it means that class does a lot of irrelevant things that should be in separate classes instead

  • @bw2
    @bw2 2 года назад

    Cries in legacy projects (5.6 :"c)

  • @NoName-oh9fh
    @NoName-oh9fh 2 года назад

    Здравствуйте, начал смотреть ваш канал недавно и вы говорите полезные вещи. Я перешёл с php на nodejs скажите пожалуйста, я сделал правильный выбор?

    • @AntonBarcelona
      @AntonBarcelona 2 года назад

      Время покажет) Но нужно не просто перейти с пхп на ноду, а перейти на жаваскрипт, нужно понимать базу и то как работает жаваскрипт.

  • @Bevallalom
    @Bevallalom 2 года назад +1

    I movements all my laravel 8 projects to php 8.

  • @yungifez
    @yungifez 2 года назад

    Laravel has a php 7.4 minimum
    That's why I might not use these yet

  • @mohammadmohammadi2724
    @mohammadmohammadi2724 2 года назад

    JWT? is it really boosts php and laravel speed?

    • @LaravelDaily
      @LaravelDaily  2 года назад

      Maybe you're confusing JWT tokens with JIT? stitcher.io/blog/php-jit

  • @PsychoTaker2305
    @PsychoTaker2305 2 года назад

    yeah but when you have 6 years old project that was rewritten for 7.4 before 8.0 release it doesn't make sense to switch to 8.0

    • @LaravelDaily
      @LaravelDaily  2 года назад

      Why? So you're planning to not upgrade at all, and then rewrite a lot of things again at PHP 8.5 or something?

    • @PsychoTaker2305
      @PsychoTaker2305 2 года назад

      @@LaravelDaily yap, 8.5 or 9 maybe. Project is big, one guy spent 3 months transfering from 5.2/5.3 to 7.2

    • @LaravelDaily
      @LaravelDaily  2 года назад +1

      Ok so you think it's not worth for you spending a day (maybe) now for a small upgrade, but instead some guy in the future will suffer for 3 months, with potentially more breaking changes and bugs?
      Upgrading to next version is much easier, later complexity gets exponential.

  • @gilneyn.mathias1134
    @gilneyn.mathias1134 2 года назад

    I'm still using Laravel 5.5 and PHP 7.4 on my job ;/

  • @rebelsdeveloper367
    @rebelsdeveloper367 2 года назад

    err what new future ? ehh im still old style forever .

  • @damodarbhattarai6969
    @damodarbhattarai6969 2 года назад

    Should I switch to node js or stick to php?

    • @L-A-O-S
      @L-A-O-S 2 года назад

      Node js more new technology.

    • @anthoniG
      @anthoniG 2 года назад +4

      Node js requires special and specific server support. PHP does not.

    • @LaravelDaily
      @LaravelDaily  2 года назад +10

      "Should I switch to BMW or stick to driving Toyota?"

    • @master0fnone
      @master0fnone 2 года назад +2

      Go build something in node js and figure it out yourself. You're in the wrong comment section to get impartial responses to your question.

    • @Fapados123
      @Fapados123 2 года назад

      Depends on the project. If it's a small API with 2-3 endpoints (maybe a microservice), use Node. If it's a big project that does many things, use PHP + Laravel (because Laravel has way more support for so many things). OOP is definitely better in PHP than Node.js (even with TypeScript). If you need async code running or native WebSocket support, use Node (because PHP can't do those). If you need high performance, use Go. There is no clear winner, use whichever fits the task better.

  • @bumblebity2902
    @bumblebity2902 2 года назад

    it ain't broke don't fix it. Period. That's why projects are slowly migrating to PHP 8.

  • @dhd180
    @dhd180 2 года назад

    Still using php5, OOP sucks