PHP Enums With Practical Examples - Full PHP 8 Tutorial

preview_player
Показать описание
Let's learn more about the enums feature that was introduced in PHP 8.1 with some practical examples.

SOME OF THE WAYS YOU CAN SUPPORT THE CHANNEL
👍 Smash the like button
🤝 Subscribe to the channel & turn the notifications on
💬 Post comments, any feedback is greatly appreciated
THANK YOU!

🛠️ TOOLS & SERVICES I USE

COURSE PLAYLIST

RESOURCES

** Affiliate Disclaimer: Some of the above links may be affiliate links, which may generate me a sales commission at no additional cost to you.

TABLE OF CONTENTS
00:00 - Intro
00:26 - Constant approach & the problem with constants
04:57 - Enums approach & the solution
09:36 - Pure & backed enums
12:48 - Get enum object from the raw value
15:04 - Methods in enums
19:28 - Static methods in enums
20:24 - Refactoring hardcoded values with enums in attributes
23:33 - Interfaces & traits in enums
24:57 - Enum rules
25:51 - Access list of all cases
26:59 - New function & reflection classes
Рекомендации по теме
Комментарии
Автор

Thank you for putting this together. I've looked online specifically for practical PHP examples and struggled to find anything of use. This video, like all of yours, is very helpful.

BrenIrwin
Автор

I got caught up with practicing this lesson. I made up my own invoice data and added some classes, some code and uploaded the values in a new table in the database so as to work together with the exercise you gave at the end of section 2. It was a great experience. I'm amazed at how much this course has thought me. Thanks Gio. The Enums feature seems really cool. I'm pleased to be learning PHP8. It makes me think that the much older versions may have been tougher to work with. lol. Thanks again Gio.

Zubbee
Автор

Love seeiythe quality of your videos just keep going up and up!

DanFletcher
Автор

I really love your video's i have really struggled with the exact use case for enum but you just made it very simple

akeemakeem
Автор

I wish I have started php with this tutorial... really profound with great examples and explanations

delisandor
Автор

Huge amount of information, thanks for everything ❤

mustafabde
Автор

Great and very helpful video as always! Thanks!

yuriymiroshnychenko
Автор

Before we had 'Enums', I would use an interface as you can have defined 'const' in them. It made them readable and easy to find in code. Obviously, 'Enums' are a more complete solution. Thanks for explaining. Appreciated.

ryanqvincent
Автор

Really insightful. Thank you a lot. I can't even imagine how much effort you put in

mirodil.kamilov
Автор

Thank you very much for explaining it so nicely and creativley

aryank
Автор

At this point I just like the videos before even watching them.

thexp
Автор

Thanks for the amazing topic 👍. Keep it coming.

cyegc
Автор

Thanks for another great lesson, at 14:28 after creating an enum case object using tryFrom, can't we just acccess the name property and display it?

aleksandrkanygin
Автор

Thank you for this amazing course!
I've some questions tho. How advanced are we if made it to this video of the course? When do you think this course will be over?
I definitely would've paid to get a complete course from you, your explainations are simple and concise. Again thanks !

mmk-
Автор

How you organize enums? We use database table for something similar, because there are more then 1000 “constants” in unique groups > group = enum.
I don’t think would be wise to create 200 files with enums.

JanPavlikdr
Автор

Amazing video as always
BTW can you make a course about Aynchronous php and ReactPHP
Would be great

morteza
Автор

Gio, the Github contains the finished code for the end of the video. It is a bit difficult to copy/paste the code when I am in the middle of the video. I am all excited with the course but this is slowing down my progress.

truthteachers
Автор

This lesson was:
• [E]xceptional
• [N]ice
• [U]nforgettable
• [M]agnificent

benderbg
Автор

Hello, I need help,
I'm working with an Enum: Error_Code: int and trying to create an error output with another Enum_Code_De: string. I'm sure it should work, I just can't figure out how.
Maybe as a topic for another tutorial

andreaseisermann
Автор

Gio, i am puzzled with the new problem is am facing at timestamp 26:39. When i enter url as "localhost:8000/invoices" everything works fine but when i enter the url as "localhost:8000/invoices/" it goes into error page. Is there a reason for this?

truthteachers