Mateus Guimarães
Mateus Guimarães
  • Видео 99
  • Просмотров 394 704
An alternative to associative arrays in PHP
👨‍💻 Learn Test-Driven Development with Laravel!
tddwithlaravel.com
Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com
👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis:
subscribe.mateusguimaraes.com
🎉 Party up:
mateusjatenee/
mateusjatenee
www.linkedin.com/in/mateusguimaraes/
Thanks for watching!
Просмотров: 14 501

Видео

The dangers of events and observers in Laravel applications
Просмотров 2 тыс.4 месяца назад
Link to the article: cosmastech.com/2024/08/18/laravel-observers-and-models.html 👨‍💻 Learn Test-Driven Development with Laravel! tddwithlaravel.com Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com 👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis: subscribe.mateusguimaraes.com 🎉 Party up: mateusjatenee/ mateusjatenee www.linkedin....
The most powerful way to use Eloquent
Просмотров 5 тыс.6 месяцев назад
Persist: github.com/mateusjatenee/persist 👨‍💻 Learn Test-Driven Development with Laravel! tddwithlaravel.com Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com 👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis: subscribe.mateusguimaraes.com 🎉 Party up: mateusjatenee/ mateusjatenee www.linkedin.com/in/mateusguimaraes/ Thanks for watc...
How to Scale Web Applications
Просмотров 1,5 тыс.7 месяцев назад
👨‍💻 Learn Test-Driven Development with Laravel! tddwithlaravel.com Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com 👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis: subscribe.mateusguimaraes.com 🎉 Party up: mateusjatenee/ mateusjatenee www.linkedin.com/in/mateusguimaraes/ Thanks for watching!
Thinking about Aggregates in Active Record
Просмотров 3 тыс.8 месяцев назад
👨‍💻 Learn Test-Driven Development with Laravel! tddwithlaravel.com Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com 👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis: subscribe.mateusguimaraes.com 🎉 Party up: mateusjatenee/ mateusjatenee www.linkedin.com/in/mateusguimaraes/ Thanks for watching!
How to properly integrate with 3rd party providers
Просмотров 2,3 тыс.9 месяцев назад
👨‍💻 Learn Test-Driven Development with Laravel! tddwithlaravel.com Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com 👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis: subscribe.mateusguimaraes.com 🎉 Party up: mateusjatenee/ mateusjatenee www.linkedin.com/in/mateusguimaraes/ Thanks for watching!
What I do before coding complex features
Просмотров 2,4 тыс.10 месяцев назад
👨‍💻 Learn Test-Driven Development with Laravel! tddwithlaravel.com Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com 👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis: subscribe.mateusguimaraes.com 🎉 Party up: mateusjatenee/ mateusjatenee www.linkedin.com/in/mateusguimaraes/ Thanks for watching!
DDD is not about code
Просмотров 1,5 тыс.10 месяцев назад
👨‍💻 Learn Test-Driven Development with Laravel! tddwithlaravel.com Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com 👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis: subscribe.mateusguimaraes.com 🎉 Party up: mateusjatenee/ mateusjatenee www.linkedin.com/in/mateusguimaraes/ Thanks for watching!
Laravel Internals: Eloquent Query Builder & Relations
Просмотров 1,1 тыс.Год назад
👨‍💻 Learn Test-Driven Development with Laravel! tddwithlaravel.com Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com 👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis: subscribe.mateusguimaraes.com 🎉 Party up: mateusjatenee/ mateusjatenee www.linkedin.com/in/mateusguimaraes/ Thanks for watching!
An introduction to Laravel's Eloquent internals
Просмотров 2,1 тыс.Год назад
👨‍💻 Learn Test-Driven Development with Laravel! tddwithlaravel.com Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com 👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis: subscribe.mateusguimaraes.com 🎉 Party up: mateusjatenee/ mateusjatenee www.linkedin.com/in/mateusguimaraes/ Thanks for watching!
Why is Javascript so advanced yet behind?
Просмотров 972Год назад
👨‍💻 Learn Test-Driven Development with Laravel! tddwithlaravel.com Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com 👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis: subscribe.mateusguimaraes.com 🎉 Party up: mateusjatenee/ mateusjatenee www.linkedin.com/in/mateusguimaraes/ Thanks for watching!
Dissecting Laravel Pulse
Просмотров 2,3 тыс.Год назад
👨‍💻 Learn Test-Driven Development with Laravel! tddwithlaravel.com Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com 👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis: subscribe.mateusguimaraes.com 🎉 Party up: mateusjatenee/ mateusjatenee www.linkedin.com/in/mateusguimaraes/ Thanks for watching!
Laravel Core 101
Просмотров 2,8 тыс.Год назад
👨‍💻 Learn Test-Driven Development with Laravel! tddwithlaravel.com Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com 👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis: subscribe.mateusguimaraes.com 🎉 Party up: mateusjatenee/ mateusjatenee www.linkedin.com/in/mateusguimaraes/ Thanks for watching!
Using fake objects in automated tests
Просмотров 2,4 тыс.Год назад
👨‍💻 Learn Test-Driven Development with Laravel! tddwithlaravel.com Sign up to 30 Days of Laravel 👉🏻 30daysoflaravel.com 👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis: subscribe.mateusguimaraes.com 🎉 Party up: mateusjatenee/ mateusjatenee www.linkedin.com/in/mateusguimaraes/ Thanks for watching!
Memory Management & Garbage Collection
Просмотров 1,5 тыс.Год назад
* Although I say return memory to the operating system, that isn't necessarily what happens. malloc() and free() are library calls that offer some abstraction on top of syscalls. malloc() and free() interact with the memory allocator/heap, which may in turn interact with the system. The underlying syscalls are somewhat expensive, and the memory allocator will try to avoid making these calls unl...
How associative arrays work internally
Просмотров 1,8 тыс.Год назад
How associative arrays work internally
PHP-FPM vs Swoole execution model
Просмотров 7 тыс.Год назад
PHP-FPM vs Swoole execution model
Event-Driven Architecture
Просмотров 1,8 тыс.Год назад
Event-Driven Architecture
Implementing a Command Bus
Просмотров 1,6 тыс.Год назад
Implementing a Command Bus
The Command Pattern
Просмотров 2 тыс.Год назад
The Command Pattern
Understanding and implementing Value Objects
Просмотров 1,5 тыс.Год назад
Understanding and implementing Value Objects
Implementing Laravel Facades from SCRATCH!
Просмотров 2,6 тыс.Год назад
Implementing Laravel Facades from SCRATCH!
Implementing our own DI container with TDD - Part 4
Просмотров 619Год назад
Implementing our own DI container with TDD - Part 4
Implementing our own DI container with TDD - Part 3
Просмотров 673Год назад
Implementing our own DI container with TDD - Part 3
Implementing our own DI container with TDD - Part 2
Просмотров 866Год назад
Implementing our own DI container with TDD - Part 2
Implementing our own DI container with TDD - Part 1
Просмотров 2,3 тыс.Год назад
Implementing our own DI container with TDD - Part 1
Thinking about modules and boundaries when writing software
Просмотров 811Год назад
Thinking about modules and boundaries when writing software
Your application does NOT need to scale
Просмотров 3,3 тыс.Год назад
Your application does NOT need to scale
Laravel Queues Lesson 3 - Laravel Horizon: setting it up, load balancing & handling logs
Просмотров 7 тыс.2 года назад
Laravel Queues Lesson 3 - Laravel Horizon: setting it up, load balancing & handling logs
Laravel Queues Lesson 2 - Failed jobs: listing, retrying and handling them
Просмотров 7 тыс.2 года назад
Laravel Queues Lesson 2 - Failed jobs: listing, retrying and handling them

Комментарии

  • @magnetoflux
    @magnetoflux 5 дней назад

    12:26 "you cannot use two workers to. handle the same request". Yes in this case you are right. What about with PHP ZTS? We can have multiple threads to achieve true parallelism. Any input on that?

  • @RubberDuckTuts
    @RubberDuckTuts 9 дней назад

    This is really really insightful. Thanks!

  • @sohupba7122
    @sohupba7122 13 дней назад

    great job pro

  • @sohupba7122
    @sohupba7122 13 дней назад

    great job pro

  • @hasanablak
    @hasanablak 23 дня назад

    thank you sir

  • @favouroladeji3722
    @favouroladeji3722 26 дней назад

    How do you handle three levels of nesting

  • @chadcglk7951
    @chadcglk7951 27 дней назад

    Great Content, friendly reminder, be careful with the empty space.

  • @abdelbarimessaoud242
    @abdelbarimessaoud242 Месяц назад

    wouldn't this make the users table have multiple NULL columns for each type if they have different fields (other than the parent's one) ?

  • @PaulAllsopp-rh5gb
    @PaulAllsopp-rh5gb Месяц назад

    You have no idea what you're talking about

  • @PaulAllsopp-rh5gb
    @PaulAllsopp-rh5gb Месяц назад

    deletes my post...lol

  • @alexalex6643
    @alexalex6643 Месяц назад

    yeah PHP suffers without "normal arrays"

  • @vedovelli
    @vedovelli 2 месяца назад

    Thank you!

    •  Месяц назад

      👊

  • @chechomancr4
    @chechomancr4 2 месяца назад

    Min 13:20 the class "UserSetthings" can be "final readonly class UserSetthings".

  • @vuejs1
    @vuejs1 2 месяца назад

    Brilliant explanation

    •  Месяц назад

      Thank you

  • @AhsanKhan89
    @AhsanKhan89 2 месяца назад

    Can't we use it with api?

    •  Месяц назад

      You can

  • @AllanSavolainen
    @AllanSavolainen 2 месяца назад

    I would probably do this only if the class is used more than 3-5 places, if it is less, always go for array for simplicity.

    •  Месяц назад

      It's not just about simplicity; an array doesn't enforce any types, is not automatically-refactorable, etc

    • @AllanSavolainen
      @AllanSavolainen Месяц назад

      It is super easy to refactor when you don't have to care about types until you actually use the value to something that cares of types.

    •  Месяц назад

      @@AllanSavolainen what I mean is that objects are recognized by IDEs and SA tools, so you can do automatic refactoring. Arrays are generic constructs that do not offer that possibility.

  • @TerabyteTy300
    @TerabyteTy300 2 месяца назад

    Brother excellent video!! It’s so good getting into the details. I appreciate how you make it digestible even for someone new like myself. Really helps the info stick.

    •  Месяц назад

      thank you!

  • @nelsonmutane1372
    @nelsonmutane1372 2 месяца назад

    Porque só vejo esse video hoje

  • @invincible9724
    @invincible9724 2 месяца назад

    Useless video no example nothing

  • @darz_k.
    @darz_k. 2 месяца назад

    Why didn't you just rerecord the video? I get an error message on your video before the error even comes up - I won't watch the video now! (that's advice)

    •  Месяц назад

      huh?

    • @darz_k.
      @darz_k. Месяц назад

      Exactly.

  • @sonoftroy8572
    @sonoftroy8572 2 месяца назад

    Flowcharts are important to do before programming

    •  Месяц назад

      they are!

  • @sonoftroy8572
    @sonoftroy8572 2 месяца назад

    Agreed

  • @ElvisIsking-u1m
    @ElvisIsking-u1m 3 месяца назад

    I found your channel because of STI. I'm hooked. Excellent how you get things working and show it, then move things from the child model to the parent and it's still working, then remove it to a trait. It demystifies what the packages do and that's really valuable. The depth of explanation is really thorough and the pacing works really well for me.

    •  3 месяца назад

      Thank you so much! I’m glad you’re enjoying it. ✌🏻

  • @ClawHammer23
    @ClawHammer23 3 месяца назад

    PHP 5.6?

  • @josiasvelazquez1095
    @josiasvelazquez1095 3 месяца назад

    Excellent video! What font do you use? It's awesome.

    •  3 месяца назад

      Thank you! The font is Operator Mono.

    • @josiasvelazquez1095
      @josiasvelazquez1095 3 месяца назад

      🫶🏻

  • @florisvandenberg7424
    @florisvandenberg7424 3 месяца назад

    This is basically the datamapper pattern inside the activerecord pattern. Horrible. I really, really, really, really hate Eloquent and Laravel as a whole.

  • @mkGarf
    @mkGarf 3 месяца назад

    I would only add that, as a general rule, it should be understood that arrays are much more efficient in terms of memory and processing. Therefore, for any process that requires iterating over collections that can grow large, arrays should definitely be used, and objects should not be used at all. For maintainability, architecture definitely matters. Given the above, as a general rule, I would use objects as a means of communication between software components within the defined architecture, but the implementations for handling large data collections should be abstractions that use arrays behind the scenes. Let's say that algorithms, which need to be implemented correctly from the start and rarely modified, should definitely be implemented using arrays.

    •  Месяц назад

      agreed

  • @marceloAK1
    @marceloAK1 3 месяца назад

    Great video. I've been using this approach a lot lately. How do you work when you have an attribute in UserSettings that must be set after the object creation and need to use it inside the notifyUser function? When do you check if the attribute was set or not? Thanks so much.

    •  3 месяца назад

      Can you exemplify? If the function takes an object as an argument, and requires property X to to be set, you can add a guard clause - e.g if ($someObject->property === null) { throw new SomeCustomException(); }

    • @marceloAK1
      @marceloAK1 3 месяца назад

      Thanks for that, that's I wanted to know.

  • @david.arl14
    @david.arl14 3 месяца назад

    i do this on last my project, for Entities in laravel implemented clean architecture. and very helpful for maintaince data return from services and repositories

  • @JustSomeObject
    @JustSomeObject 3 месяца назад

    what if i want to early exit from say the 2nd pipe and skip the rest of the pipes?

  • @codyscorner1829
    @codyscorner1829 3 месяца назад

    Well this is not a array. An array is one data type. When you are putting in different data types it's more a data container or table.

    •  3 месяца назад

      It’s an associative array.

    • @jediampm
      @jediampm 3 месяца назад

      Its only an assoc if it has keys as string, otherwise if it is a list of objects so it is an indexed array. if you have an object and cast to an array, it will be an assoc array. to sum up, for example, if you fetch from a db more that one row, than will be a list of array assoc or stdclass ( so indexed array), only a row turn into stdclass or array assoc.

  • @saytaimoor
    @saytaimoor 3 месяца назад

    Video title is misleading. A handy solution when it come to simple read-only operations sure, but it is by no means an "alternative" to the arrays. Think about what you can achieve with arrays when it comes to data manipulation and processing. Not to mentioned numerus PHP's build in and custom-tailored functions to process data.

    •  3 месяца назад

      You can achieve all of that still. Anything specific you're thinking about?

  • @QuintessentialDio
    @QuintessentialDio 3 месяца назад

    Years of writing PHP, and i still learnt something new today, thanks lad.

    •  3 месяца назад

      Happy to help!

    • @cafnix
      @cafnix 3 месяца назад

      My boss, I taught you have learnt everything you need in PHP

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

    Cool do more PHP videos and courses.

    •  3 месяца назад

      will do!

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

    What you call arrays in other languages is actually vectors if you are coming from an actual programming language.

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

      Actually, arrays and vectors are different things. A vector is essentially a dynamic array.

    • @jediampm
      @jediampm 3 месяца назад

      Actually, in languages like c, c sharp, java and go, vectors has a fix length / one dimension and only allow primitive types. So an array, arrayList, Map, etc, are dynamic vectors that allow more complex types and the length is dynamically updated.

    •  3 месяца назад

      @@jediampm It’s the other way around. e.g in C# an Array has a fixed size, while a List<T> will grow/shrink dynamically.

    • @jediampm
      @jediampm 3 месяца назад

      your are correct, my mistake writing for too long PHP that mix up concepts like array / matrix, etc in another languages, not only C Sharp.

  • @DavidSmith-ef4eh
    @DavidSmith-ef4eh 4 месяца назад

    Yeah, I do this all the time. Makes refactoring much less stresfull. Also, using Propel ORM for the sam reaoson. It allows you to change the database schema without having to worry that code will break. Too bad worse ORM solutions like Eloquent are more popular than Propel. I guess PHP developers suck.

    •  3 месяца назад

      I’ve never used Propel. I’ll take a look!

    • @DavidSmith-ef4eh
      @DavidSmith-ef4eh 3 месяца назад

      it seems to be abandoned.. very slow updates. abandoned project. I tried to find an replacement ORM but none of them is as good as propel.

  • @BrunoBernard-kn6vt
    @BrunoBernard-kn6vt 4 месяца назад

    It is Value objects ?

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

      They can be VOs, but not necessarily.

    • @BrunoBernard-kn6vt
      @BrunoBernard-kn6vt 4 месяца назад

      thanks for replying ! Ex. Let's say I have an action, i use an object instead of a array to transport the value right ? basically it reduce the need for Laravel Validators. right ?

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

      @@BrunoBernard-kn6vt That’d be a DTO. It doesn’t eliminate the need of a validator because you still want to validate messages at the borders (e.g HTTP). A value object would be - for example, an Email object, that could enforce the string to be a valid email, a ZipCode object, or a Money object. These would typically be used in models (through cast operations in Laravel).

    • @BrunoBernard-kn6vt
      @BrunoBernard-kn6vt 4 месяца назад

      Thank you so much for clarifying, and if i have to organize these types objects where should I namespace it? Enums goes to Enums folder. Value Objects goes to ValueObjects folder. Objects folder perhaps?

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

    One (still) useful usage of array is a pseudo Tuple: function doSomething(){ if (somethingWentWrong()){ return [null, new SomeBusinessException()] } return [SomeDto, null]; } function someConsumer(){ [$data, $error] = doSomething(); // } A pseudo Result<T> monad, but until PHP had generic, Tuple will have to suffice

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

      Yeah, I find usages where it’s short-lived perfectly valid.

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

    Of course this is good approach to replace assoc arrays with objects, but it would be nice to see such approach in framework configurations instead of arrays/yaml files.

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

      Yeah, I’d very much enjoy that.

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

    laravel throws errors when you access a key that isn't set i thought that was the default behaviour, maybe i don't know php that well

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

    this has become a LOT more relevant since PHP introduced constructor-defined readonly properties. Creating value objects, DTOs whatever is now pleasant and elegant.

  • @LucasAlves-bw9ue
    @LucasAlves-bw9ue 4 месяца назад

    Thats solid principles applied into php. Thats awesome!

    •  3 месяца назад

      Glad you liked it!

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

    It had never occurred to me to treat arrays as objects.

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

    This is all dependable on the context... good thing for complicated data but overkill for some simple data... Generally the video is a good hint about what can you do in PHP as a programming language. "Chose your 'weapons' wisely!"

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

      @@easyvideott7505 Simple data becomes complex when suddenly you need to check what to send to a function all the time. When something is added but not documented. When something is expected but not provided. A class can give you default values. An array can't. Create a class, save your colleague.

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

      @@CottidaeSEA Exactly! If you need data complex as that, surely it would be better to make a class and pass the data as an object. All I wanted to say in the previous comment is that it would be wrong to say: "Never use simple arrays in PHP, always use Class objects".

    •  Месяц назад

      "Simple data becomes complex" - I"ll save that!

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

    The timing for this video couldn't be better as I was literally talking about these exact points yesterday with my team. Great content man, kudos from Brazil! Also it was awesome to see u on Laracasts as well 🤩 Parabéns meu bom

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

      Valeu!

  • @AsmitNepali-hb9vh
    @AsmitNepali-hb9vh 4 месяца назад

    Nice video, what if we have numbers of array elements like current_period and previous_period, is it good to pass on constructor ? ruclips.net/video/7g8WCApiz04/видео.html

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

    Honestly, I'm quite baffled that PHP devs don't use classes more. "We need to pass an array to this function" okay, so use get_object_vars? Create a toArray method? The good thing about having a class is that you can add default values to the state and easily create a copy of it, along with a strict schema to follow.

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

      Yeah, I’m honestly surprised by some reactions to this video, which I considered fairly mild.

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

    your username in comments doesnt render. wtf?

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

      Yeah I’ve noticed that as well lol

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

    By far the biggest thing to be aware of with Swoole is that if your code encounters an error, the entire worker has to be restarted, which kills all requests that it had been handling concurrently at that time. In FPM, just that request is affected. You have to be a LOT more defensive with your code in Swoole, which can be difficult sometimes due to PHP's ancient error model.

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

    Mateus, I didn't watch the whole video, but it appears you're trying to do what the *spatie/laravel-data* package does, just take a look a it

    •  Месяц назад

      It's not about a package