Laravel's secret weapon: macros (watch me code)

  Рет қаралды 18,905

Aaron Francis

Aaron Francis

Ай бұрын

Customizing Laravel to do exactly what I want, thanks to macros and the container.
Want to support the channel? Please get in touch! aaronfrancis.com/sponsorships

Пікірлер: 149
@PunterMcGavin
@PunterMcGavin Ай бұрын
That macro/constructor stuff is absolutely disgusting. I love it.
@aarondfrancis
@aarondfrancis Ай бұрын
🫡 at your service
@DevduttaBain
@DevduttaBain Ай бұрын
"My site, My video" 😆🤣😆🤣
@elmalleable
@elmalleable Күн бұрын
My rules
@DivDax
@DivDax Ай бұрын
Please more content like this. So much hidden gems we all can learn from. Keep it up!
@yanuar1420
@yanuar1420 Ай бұрын
hey man, you radiate a positive energy that make me more enthusiastic to code. Your attitude, confidence, enthusiasm, curiousity, adventurous and that "My site, my video" sass is contagious! Thank you for sharing that Please keep creating videos. You rocks!
@aarondfrancis
@aarondfrancis Ай бұрын
Thank you so much! I want to be a positive force, so that's encouraging
@LeonardoRuizOberle
@LeonardoRuizOberle 20 күн бұрын
I love it in Laravel. We extend a bunch of main Laravel code to cover our requirements. Awesome.
@Leonhart_93
@Leonhart_93 Ай бұрын
YES, reading Laravel's source files is a game changer. Not only you understand better what is the thing doing exactly, but you can find a lot of other useful functions and snippets in the process. And also I have been using DB query builder macros to add new functions to it, like one that automatically selects columns with an alias name, based on a map array loaded at the macro's definition, that maps column names.
@aarondfrancis
@aarondfrancis Ай бұрын
I love to macro the query builder! Super powerful
@DesolatorM
@DesolatorM Ай бұрын
I love the vibe of: let's do this no because a book say it's right, but because it sound interesting/fun, great video.
@StefanMalic
@StefanMalic Ай бұрын
Ay Ay Ron (sorry, intrusive thoughts won), this is the first time I'm seeing someone actually go beyond the basics in Laravel and talk about approaching Laravel not from a purely consumeristic perspective, but rather from an engineering perspective.
@aarondfrancis
@aarondfrancis Ай бұрын
Haha it's ok, not the first time someone has called me that. And probably not the last!
@Tuto1902
@Tuto1902 Ай бұрын
I think I might need to watch this video a couple more times at 0.5 speed to fully grasp what I just saw. It's looks easy but magical at the same time.
@Nittiyh
@Nittiyh Ай бұрын
Fun video! It's always interesting to see what's under the hood and all the undocumented ways you can use the framework. An approach for this particular problem that I like to use is to have a "url" attribute accessor on my model, and have that be responsible for handing me the proper URL. That way, I don't even need to remember my route name throughout the project.
@neverything
@neverything Ай бұрын
This was fun, more of this please. Thank you Aaron!
@tealiedie
@tealiedie Ай бұрын
I know it's kinda over-engineered, but damn, thanks for showing this laravel gem! more videos please
@aarondfrancis
@aarondfrancis Ай бұрын
Haha fun, right?
@Nettak012
@Nettak012 Ай бұрын
You just performed magic upon us with Laravel and PHP, my brother! Super educational and very informative. Thank you so much!
@lasserafn3789
@lasserafn3789 Ай бұрын
11:20 love how you didn't cut the video. Honest and funny
@aarondfrancis
@aarondfrancis Ай бұрын
Haha much more fun that way
@sifrious
@sifrious Ай бұрын
Love the format, definite pairing vibes or the most useful parts of a stream. Hope there's more like this
@waleedmasoom6326
@waleedmasoom6326 Ай бұрын
That starting snap and pop of the hands, asmr vibes. I can already tell this will be great!
@ihzakarunia2408
@ihzakarunia2408 Ай бұрын
ikr, i dont know how he did that with his hand..
@martomystery
@martomystery Ай бұрын
I had no idea this is how useful macros are.Am definitely exploring their use now.Awesome video!!!
@swancompany_inc
@swancompany_inc Ай бұрын
Great video! Really enjoy hearing you think out load when you're trying to figure things out. I think a scripted screencast is very valuable but watching an experienced developer wrestle with things gives a different look. Thanks Aaron! -Mike
@something00witty
@something00witty Ай бұрын
Love watching the process!
@ZamirMubashir
@ZamirMubashir Ай бұрын
More videos like these! This was an absolute delight!
@n0ta
@n0ta Ай бұрын
Fantastic content! I love to see how other people reasons about this kind of problems.
@kedniko
@kedniko Ай бұрын
Your content is truly unique and valuable!
@JustPlayerDE
@JustPlayerDE 19 күн бұрын
i do really like this kind of video, for me at least it is easier to learn when i watch someone actually coding something ^^
@lautarolopez5372
@lautarolopez5372 Ай бұрын
Your way of conveying knowledge is very pedagogical. You are a great programmer and disseminator of knowledge! I really like your videos. Keep it up!
@lukmauu
@lukmauu Ай бұрын
Holly cow, I always saw you around X, but I never thought too much about you. But after watching this my jaw dropped, we must be on Laravel lore forever as one of the greats.
@aarondfrancis
@aarondfrancis Ай бұрын
Haha this is funny to me. Glad you're here!
@pindab0ter
@pindab0ter Ай бұрын
This is absolutely great stuff! Just showing a way how to do advanced things in Laravel is great!
@pindab0ter
@pindab0ter Ай бұрын
I just want to reiterate how much I appreciate that you made this. There's a LOT of beginner content out there. I really appreciate you making things on intermediate and advanced topics, too. I feel that the way in which you do it (showing the process, rather than just the result) makes it less intimidating. Finally, you're not solving a specific problem, you're using the problem to showcase a method of finding a solution, which is awesome as well! You got me gushing over how much I appreciate this video!
@jondoe79
@jondoe79 Ай бұрын
Mind blowing and made me think outside the box. 👍
@renzomarlperalta
@renzomarlperalta Ай бұрын
GOLD CONTENT! More power broda!
@anderskozuch7838
@anderskozuch7838 Ай бұрын
You are an inspiration and very much appreciated Aaron! Thanks so much for this video, learned a lot:)
@SimoneFolador
@SimoneFolador Ай бұрын
Great tutorial. I've never used Macroable before, it sure is a useful tool. Thanks!
@adammenczykowski
@adammenczykowski Ай бұрын
Been building apps for some time and i just learnt a lot! Thanks!
@arcborn
@arcborn Ай бұрын
I've never messed with macros, but I want to mess with them now! Would love to see more content like this!
@renatolovato
@renatolovato Ай бұрын
"I'm just going to leave it as it is." That's a Perfect approach. Nowadays, developers spend so much money and time on things that someone may ask to do something with them one day. Let's deal with that later when it is needed!
@TheMokx1
@TheMokx1 Ай бұрын
This is a great video about how to think! I would personally keep the original route URL and then redirect to the external URL in the show method, so when we add page statistics, trends, etc., that would also work for the external posts as well.
@eliotalderson2892
@eliotalderson2892 Ай бұрын
We need more videos like this
@SaiyanJin85
@SaiyanJin85 Ай бұрын
That use of the weakmap was brilliant
@jackjaguar3837
@jackjaguar3837 Ай бұрын
Thanks Aaron!
@robwatson826
@robwatson826 Ай бұрын
Great video, I absolutely hate this with every fibre of my being due to the sheer complexity introduced here 🤣 but it's fascinating nonetheless. Would love to see more videos like this! Thanks for sharing
@HannesVermeire
@HannesVermeire Ай бұрын
Great content Aaron ✌😊✌
@andrewpratt7177
@andrewpratt7177 Ай бұрын
I have typed dd('here') and dd('1234') at least 7 million times in the last 10 years! I quite like Spatie's Ray product which essentially does the same thing but feels less blunt 🙃........Very relatable and enjoyable video - keep it up!
@xinotsultan3867
@xinotsultan3867 Ай бұрын
Its like hidden gem for me, even i doesnt use it, but still is good knowladge
@ahmad-murery
@ahmad-murery Ай бұрын
I don't like it, I love it, More videos like this are always welcome. Thanks Aaron!
@bphilsochill
@bphilsochill Ай бұрын
Love the process and learned something new! Oh yeah, for your analytics, I came from twitter.
@umairsaeed5925
@umairsaeed5925 Ай бұрын
The pause part just hilarious 😅 by the way what a effort need more these types of videos
@aarondfrancis
@aarondfrancis Ай бұрын
Classic Producer Steve adding those funny sound effects
@umairsaeed5925
@umairsaeed5925 Ай бұрын
@@aarondfrancis hats off for Steve already following him on twitter much appreicated his dedication in work
@citricguy
@citricguy Ай бұрын
Love it!
@gilneyn.mathias1134
@gilneyn.mathias1134 Ай бұрын
This is funny... I watched this video a couple of days ago and today i found out a problem with Laravel+Mongo+Failed Queues and remembered of this video and implemented an 'extend' to 'fix' a laravel base class... 😅 Thanks man! (The base class isn't Macroable, tho, but i have access to the needed params from the $app instance 👌)
@aarondfrancis
@aarondfrancis Ай бұрын
Heyo! That rules
@vlkf
@vlkf Ай бұрын
You create amazing tutorials. Have you consider to create full laravel course? Thank you
@ZiPMo85
@ZiPMo85 Ай бұрын
Please more of this please
@tanzimibthesam5861
@tanzimibthesam5861 Ай бұрын
This could have been the best thumbnail for a Mac promotion
@MikkelMalmberg
@MikkelMalmberg Ай бұрын
The new studio is looking suuuper nice
@aarondfrancis
@aarondfrancis Ай бұрын
Thank you 🤗
@isabelphillips451
@isabelphillips451 Ай бұрын
I enjoyed the video, I laughed almost all through the video .... the video reminds me or me when coding 😂😂😂😂😂
@LenWoodward
@LenWoodward Ай бұрын
This is the type of content I love. Bending the framework to our will. This is the stuff that makes you feel like a programming wizard
@xiCO2k
@xiCO2k Ай бұрын
SEEEEEEEEEEEEEEEEEEE YAAAAAAAAAAAAAAA, loved that!
@ekroon
@ekroon Ай бұрын
This is gold
@MouayedElhak
@MouayedElhak Ай бұрын
very very nice
@jonashansen2512
@jonashansen2512 Ай бұрын
Like the idea, I would probably pull the macro out into a mixin and stick both the generator & mixin in an Extensions directory to signal it’s extending the framework. :)
@aarondfrancis
@aarondfrancis Ай бұрын
Oh that's a nice idea!
@MattiaMarchiorato
@MattiaMarchiorato 4 сағат бұрын
Ahah, but we liked it Aaron ❤
@clementmmas
@clementmmas Ай бұрын
I both love it and hate it. That kind of stuff bit me a few times so I've learned to settle for much more boring solutions. Very entertaining video though. I'd love to see more advanced content like this.
@leroybakker8774
@leroybakker8774 Ай бұрын
Hey Aaron, Love your content. Just wondering; would it be possible to request an instance of your custom call using the container aswell?
@stevebauman
@stevebauman Ай бұрын
Loved this! lol imagine if Laravel implemented final classes and prevented you from *gasp!* extending its implementations
@aarondfrancis
@aarondfrancis Ай бұрын
Can you imagine
@BenHolmen
@BenHolmen Ай бұрын
Love macros! We use a bunch of carbon and eloquent macros
@akhelijmohamed1063
@akhelijmohamed1063 Ай бұрын
More videos like that 🙏
@antonmykhailovskyi447
@antonmykhailovskyi447 Ай бұрын
This looks so terrible and so impressive at the same time. It`s just amazing to know that you can do it even in such pretty weird way. Great video Aaron, thank you so much for such high-quality content!
@aarondfrancis
@aarondfrancis Ай бұрын
> so terrible and so impressive 🫡
@dennisadamczyk
@dennisadamczyk Ай бұрын
9:03 I didn't know that people speaking english know the german word "verboten" which means forbidden 🤔 Apart from this, I really appreciate that you make more videos now. They are so high quality, even the fact that there is close to no cut when you are speaking... wow. In my videos I mispronounce something every other sentence 😅 (German is a difficult language 😂) You are also explaining the things very close to how my thought process is. Hoping to see more of these kinds of videos!
@aarondfrancis
@aarondfrancis Ай бұрын
Haha sometimes things pop out of my mouth and I'm like... where did that come from! Glad you enjoyed it :) I enjoyed making it. I'll do more videos like this one!
@rudiedirkx
@rudiedirkx Ай бұрын
Routes are cached & serialized, so Closures are probably not great. You should try it with cached routes. Empty weakmap? But it is fun making computers do what you want! Just test it with production config before you go to production :D
@aarondfrancis
@aarondfrancis Ай бұрын
Closures are great for demos like this 🙂 How would you extend differently? Would love to see some code!
@thewizardguy1337
@thewizardguy1337 Ай бұрын
man i was with ya until the weakmap generator thing... i stopped comprehending at that point ! 😂
@fuzzyfox0
@fuzzyfox0 Ай бұрын
This feels like a lot compared to just adding a redirect within your `ArticleController`'s `show` method at the start that does the sniff test for external, and responding with a redirect. Cool to see the process you followed for utilizing macro's though 😁
@aarondfrancis
@aarondfrancis Ай бұрын
Yup! Agreed!
@TheMoonWatcher
@TheMoonWatcher Ай бұрын
Not an SEO person, but I imagine that will have some sort of SEO implications. I would imagine linking directly to the external URL is better than having the crawler follow a URL only to find it redirects you to an external site. Also it would be more transparent to the user to be able to see that the URL is external. But I do agree that your solution would be easier to implement 😂
@elikemdaniels7806
@elikemdaniels7806 Ай бұрын
Hi, Aaron. I have a question. Not directly related to Macros, but Laravel. 😁 When it comes to choosing a CMS to use with Laravel, which have you used before and which one(s) would you recommend for better editorial experience? Thanks.
@flipperiflop
@flipperiflop Ай бұрын
Oh, so that is what the macros are! Also how would you document what you have done so you can understand it in 6 months when you have to work on that feature again?
@aarondfrancis
@aarondfrancis Ай бұрын
I usually put them all in a single MacroServiceProvider so I know where to look when I come back to a project
@TravisNorthcutt
@TravisNorthcutt Ай бұрын
Producer Steve with the brutal crickets edit, ouch 😂
@aarondfrancis
@aarondfrancis Ай бұрын
The nerve
@MauriceKindermann
@MauriceKindermann Ай бұрын
Cool idea and useful to see your way of debugging and unpacking framework code. But I was scratching my head the whole time, can't this entire thing be handled by 1, maybe 2 if/elses to returns the correct url? 🤔
@aarondfrancis
@aarondfrancis Ай бұрын
Maybe! But that's no fun
@ltroya
@ltroya Ай бұрын
Why is the use case of that addGenerator function? Cache maybe? If so, doesn't it get destroy after the request has finished?
@JimishFotariya97
@JimishFotariya97 Ай бұрын
I thought of adding Accessor on model itself. But hey my brain, my logic ;)
@smirkastart5029
@smirkastart5029 Ай бұрын
I like your funny words magic man
@aarondfrancis
@aarondfrancis Ай бұрын
Haha thank you 😂
@stephenr85
@stephenr85 Ай бұрын
I use a top of the line Macbook Pro, and use Sail instances for dev (with a proxy manager layer to run multiple at the same time). The further into a project I get, the more painful it gets to do a quick dd() or run phpunit tests. Do you have any tips on dev environment setup and speed?
@aarondfrancis
@aarondfrancis Ай бұрын
I just use Laravel Herd locally!
@videolocos413
@videolocos413 7 күн бұрын
What is your editor's theme?
@user-ig9se9xq1x
@user-ig9se9xq1x Ай бұрын
Damn fr
@buddytynes8633
@buddytynes8633 Ай бұрын
This might be a dumb question, if so my bad... Why not just rebind this CustomUrlGenerator?
@aarondfrancis
@aarondfrancis Ай бұрын
Dunno! Gimme a code sample
@buddytynes8633
@buddytynes8633 Ай бұрын
​@@aarondfrancis Something like this in your service provider? I'm just a jr dev don't listen to me lol. `public $bindings = [ 'url' => MyCustomUrlGenerator::class, ];`
@BernhardK91
@BernhardK91 Ай бұрын
If you meant the German word „verboten“ in 09:06, it means „forbidden“. 😊
@aarondfrancis
@aarondfrancis Ай бұрын
Yes! That's it!
@ScottZirkel
@ScottZirkel Ай бұрын
I don't have to like this, but I do.
@bombardo2489
@bombardo2489 Ай бұрын
Hey man i heard that laravel is batteries included. is the auth system secure
@chrispian
@chrispian Ай бұрын
It's very robust. But if you don't like it, remove the batteries and put in your own. I use LDAP at work with Laravel, for example. We also have a few apps that use SSO with custom IDP. On most of my personal projects the built in stuff is perfect.
@aarondfrancis
@aarondfrancis Ай бұрын
Yes, it is indeed secure
@bombardo2489
@bombardo2489 Ай бұрын
thank you guys.
@Betacak3
@Betacak3 Ай бұрын
9:03 sounds to me like you're saying the word "verboten", in which case it would be German and mean forbidden.
@aarondfrancis
@aarondfrancis Ай бұрын
Yes! That's it! Thank you
@arturpendrag0n270
@arturpendrag0n270 Ай бұрын
Neat trick with the macro stuff. Looks like its called MonkeyPatching in other places. I will see if I can add this at work #evil :D
@aarondfrancis
@aarondfrancis Ай бұрын
Godspeed 🫡
@Meeshalkumar
@Meeshalkumar Ай бұрын
Route would always consider your domain. You just need to construct your external urls any other way other than route methods. It’s a very strange video, creating a problem which doesn’t exists. At least till now 6:26
@aarondfrancis
@aarondfrancis Ай бұрын
Fun though right?
@Meeshalkumar
@Meeshalkumar Ай бұрын
Sorry but this is wrong in every sense possible. And not fun at all for me. Think of new devs who watch your videos. Anyways, you do whatever you want. I am no police. Have a great day 👍🏼
@adampatterson
@adampatterson Ай бұрын
at 8:30, what shortcut was this?
@aarondfrancis
@aarondfrancis Ай бұрын
Navigate > go to by reference > file structure
@adampatterson
@adampatterson Ай бұрын
@@aarondfrancis Nice, thanks! I sometimes remember to use the navigation bar, but this looks slightly more purpose built.
@emircanerkul
@emircanerkul Ай бұрын
I think no need to add $url = null also
@gosnooky
@gosnooky 22 күн бұрын
Verboten == Forbidden (German)
@ryanb509
@ryanb509 Ай бұрын
This is absolutely unhinged and I'm here for it.
@wagnerfernandes8780
@wagnerfernandes8780 Ай бұрын
23 minutes? You figure out things too quickly, I would have wasted a day on that 😅
@younesessaadani9303
@younesessaadani9303 Ай бұрын
Is he really want to share macros feature or just piss off "clean code readers"v
@kwyaza
@kwyaza Ай бұрын
Great video! This is my problem with modern "Laravel" PHP. Antipatterns, the interpreter has to parse all these 3 million layers. Unlike Java or C#, which is compiled down, it's fine to have so many layers.
@aarondfrancis
@aarondfrancis Ай бұрын
Nah I think it's probably fine!
@testdeim
@testdeim Ай бұрын
yeah man! this is bullshit. you should extend Laravel url generator and set it as app('url') service.
@aarondfrancis
@aarondfrancis Ай бұрын
I'm not sure I'd call it bullshit... But ok! Show me some code, I'm not sure what you mean
@ivan.jeremic
@ivan.jeremic Ай бұрын
Now I understand why JavaScript won and everything will eventually be written in it.
@aarondfrancis
@aarondfrancis Ай бұрын
Huh
@thedailycutline278
@thedailycutline278 Ай бұрын
As a nextjs dev, i think people should move on, life as a dev should not be as tough as laravel makes it to be.
@languagelearningexperience6814
@languagelearningexperience6814 Ай бұрын
​@@thedailycutline278 interesting, have you made anything in laravel? I find it refreshingly easy.
@aarondfrancis
@aarondfrancis Ай бұрын
I appreciate all your comments but you don't have to watch these videos if you don't like them!
@Argie02
@Argie02 Ай бұрын
​@@aarondfrancishe just hates php so bad haha
@israeliloba
@israeliloba Ай бұрын
This is higher level thing, didn't understand shit
@DarylLegion
@DarylLegion Ай бұрын
"you don't have to like this" me: smashing the dislike button
@thedailycutline278
@thedailycutline278 Ай бұрын
As a Nextjs developer, i just have one thing to say, i have never seen such a complicated framework, adding to that it uses php😢
@aarondfrancis
@aarondfrancis Ай бұрын
That's ok
@reihanboo
@reihanboo 23 күн бұрын
If it were me I would just @if($article->markdown_file) href="{{ route('article.show', $article->slug.$article->public_id }}" @elseif(!$article->markdown_file && $article->external_link) href="{{ $article->external_link }}" @endif Am I cooked?
@aarondfrancis
@aarondfrancis 23 күн бұрын
No more cooked than the rest of us! Honestly no, that's totally reasonable. I'd probably wrap that up in a method in the Article model itself so that it's easier to use throughout the app, but it's not crazy!
Make faster outbound requests with Laravel (10x faster, actually)
5:28
Laravel Horizon: queue monitoring + configuration
14:54
Aaron Francis
Рет қаралды 14 М.
FOOLED THE GUARD🤢
00:54
INO
Рет қаралды 62 МЛН
Can You Draw A PERFECTLY Dotted Line?
00:55
Stokes Twins
Рет қаралды 47 МЛН
MEGA BOXES ARE BACK!!!
08:53
Brawl Stars
Рет қаралды 33 МЛН
Wait for the last one! 👀
00:28
Josh Horton
Рет қаралды 106 МЛН
How to Reprogram Tetris By Playing It - Behind the Code Leveled Up
31:58
Displaced Gamers
Рет қаралды 68 М.
Supercharge Markdown with Laravel
31:26
Aaron Francis
Рет қаралды 8 М.
When should you pick Laravel over WordPress?
26:54
viewSource
Рет қаралды 5 М.
5 Design Patterns That Are ACTUALLY Used By Developers
9:27
Alex Hyett
Рет қаралды 194 М.
Laravel solved race conditions
14:13
Aaron Francis
Рет қаралды 14 М.
Ryan Dahl introduces JSR at DevWorld 2024
29:13
Deno
Рет қаралды 99 М.
Dan Is Back, Let’s Rethink React
1:15:43
Theo - t3․gg
Рет қаралды 77 М.
Laravel + Cloudflare D1 speedrun
7:43
Aaron Francis
Рет қаралды 13 М.
Migrating from Postgres to SQLite with Kent C. Dodds
57:02
Aaron Francis
Рет қаралды 7 М.
What Makes A Great Developer
27:12
ThePrimeTime
Рет қаралды 147 М.
THEY WANTED TO TAKE ALL HIS GOODIES 🍫🥤🍟😂
0:17
OKUNJATA
Рет қаралды 3,6 МЛН
Типичная МАМАША (смешное видео, приколы, юмор, поржать)
0:59
Натурал Альбертович
Рет қаралды 4,6 МЛН