Laravel: Create Public API with Cache and Rate Limits

  Рет қаралды 46,933

Laravel Daily

Laravel Daily

Күн бұрын

Пікірлер: 136
@mibrahim4245
@mibrahim4245 2 жыл бұрын
It's not useful, it's extremely useful!! You talked about a loooot of things!! What an intense and clear tutorial.. God bless you ..
@MarkKulishov
@MarkKulishov 3 жыл бұрын
very simple, short, fast and to the point. I really like this video format. When you do the same after the video and it really works! Thank you, Povilas!
@JouvaMoufette
@JouvaMoufette 3 жыл бұрын
Very useful stuff! Love the use of the Observer pattern to clear the cache. Makes that very simple to handle
@webcodingoprogrammingtips2090
@webcodingoprogrammingtips2090 3 жыл бұрын
Really interesting approach, thanks for sharing it with us
@bhanukrsingh
@bhanukrsingh 3 жыл бұрын
I am a wordpress developer, and your videos keeps inspiring me to learn laravel.
@kickass1179
@kickass1179 3 жыл бұрын
it is a no thinker mate, go learn Laravel, start with Laracasts!
@bhanukrsingh
@bhanukrsingh 3 жыл бұрын
@@kickass1179 Yeah, I had Laracasts subscription but it was very difficult with my full time job. Weekends are all I get, but I guess I will have to come up with some strategy to actually find time. These videos keep my interest high.
@rahulgohilvlogs1820
@rahulgohilvlogs1820 3 жыл бұрын
@@bhanukrsingh Find Coders Tape 5.8 course on KZbin which is free to start.
@birenjung
@birenjung Жыл бұрын
I have been studying your Laraval Roadmap for one month. I am really grateful for this.
@alimransujon6388
@alimransujon6388 3 жыл бұрын
Every time I see your video, I learn something new. Watching your videos since 2020. Don’t stop it. Keep up. You are a legend.
@danwah
@danwah 3 жыл бұрын
Great video! For anyone that doesn't know you can make laravel create all the standard API methods, such as index, store, show, create, update and delete when you create a controller by passing in --api flag. E.g. PHP artisan make: controller ExampleController --api --model=ExampleModel
@СтаниславЧетвериков-з2м
@СтаниславЧетвериков-з2м 3 жыл бұрын
Спасибо большое) Вроде бы уже сам знаю эту тему, но нюансы очень полезны. Ради нюансов и смотрю каждый день
@vivdroid
@vivdroid 3 жыл бұрын
You are doing great job sir that’s why I purchased your courses to support you.
@anthoniG
@anthoniG 3 жыл бұрын
Yep same. I am learning so muh useful info. I bought the full subscription.
@hot4mix
@hot4mix 2 жыл бұрын
Fantastic as usual, @8:34 tho. I think you were going to mention Carbon, but you went on to Observers. the Cache::remember 2nd argument can be an instance of carbon, Which means you can use *Carbon::today()->endOfDay()* and it will be cached for that exact timeframe. Or you can also use Laravel's today helper: *today()->endOfDay()*
@ErickJeronimo
@ErickJeronimo 2 жыл бұрын
Thanks for pointind that
@mhmdomer
@mhmdomer 3 жыл бұрын
Very informative! thanks, Povilas. I think it is a good practice to select only the fields you want from the database, especially if you are getting a big collection " in this case CovidCase::all()", it is better to use "CovidCase::select(['cases', 'report_date'])->get()" to use less memory by loading fewer data to the memory.
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Good catch, thought about it myself when re-watching the video after publishing.
@lupanvi
@lupanvi 3 жыл бұрын
Using that approach, how could I format the date?
@mhmdomer
@mhmdomer 3 жыл бұрын
@@lupanvi you can use the same technique used in the video ( using resource class )
@lupanvi
@lupanvi 3 жыл бұрын
@@mhmdomer ok, but I was thinking without resources, to avoid it
@mhmdomer
@mhmdomer 3 жыл бұрын
@@lupanvi you can call $case->report_date->format("Y-m-d") on the blade file where you want to render it
@valtrgr3755
@valtrgr3755 3 жыл бұрын
the cache and observer thing is new for me. thank you
@redayoub
@redayoub 3 жыл бұрын
Thanks for the video, I suggest adding pagination to limit the returned data
@phil86_
@phil86_ 3 жыл бұрын
Great tutorial, as always. Showing the use of Postman is also important.
@zakariajawas
@zakariajawas 3 жыл бұрын
Thank you for your time and effort, your topics are always useful
@rikiamaru
@rikiamaru Жыл бұрын
this is exactly what im looking for, thank you so much
@raykudjie2365
@raykudjie2365 3 жыл бұрын
I learned something new each time with your videos!
@TemoTemo1995
@TemoTemo1995 3 жыл бұрын
Omg so good explained i finally understood many things in a single video. Keep it short 🤘
@abdulbasitsalah2918
@abdulbasitsalah2918 3 жыл бұрын
the cache was totally new to me, it was very usefull video
@ziakhan-vv9ts
@ziakhan-vv9ts 2 жыл бұрын
Very useful in a short video, api, observer,postman, api protection 👍
@juliopeluciofox
@juliopeluciofox 3 жыл бұрын
Very helpful your videos Povilas, really like how simple thing are when you explain.
@youngengineer8033
@youngengineer8033 3 жыл бұрын
Sir you are the best one day i will remind you that. Do you remember when u had 66k subscription I told u you are gonna have 1 M subscriber than you will say i dont remember what u said.
@binodthakur6113
@binodthakur6113 3 жыл бұрын
Excellent topic and Insight - always each and every video on Laravel is awesome. Thanks a lot has learned a lot from you. God bless you. Love from India.
@holiqibrahim
@holiqibrahim 3 жыл бұрын
I really like your tutorial, very short and easy to understand
@LaravelLover
@LaravelLover 3 жыл бұрын
Great tips Povilas, Thank you so much for your efforts
@sumailsasumi1294
@sumailsasumi1294 3 жыл бұрын
Its make laravel so powerfull i love it
@syedkhizer857
@syedkhizer857 2 жыл бұрын
Really good video as always. Thanks A LOT!
@bozok1903
@bozok1903 3 жыл бұрын
I learn lots of things from you. Thanks a lot.
@ErickJeronimo
@ErickJeronimo 2 жыл бұрын
Great video, thanks!
@GergelyCsermely
@GergelyCsermely 3 жыл бұрын
Thanks very interesting again.
@asimal-tayeb5355
@asimal-tayeb5355 3 жыл бұрын
simple, helpful thanx.
@kyledoesdev
@kyledoesdev 8 ай бұрын
super helpful, thank you!
@hassamulhaq7762
@hassamulhaq7762 2 жыл бұрын
Love this tutorial 🤩
@slablife
@slablife 3 жыл бұрын
Wow, this is gold!
@izniburak
@izniburak 3 жыл бұрын
Great tutorial! Thanks.
@twentxx
@twentxx 2 жыл бұрын
Thank you! Laravel 😍
@8bitenial313
@8bitenial313 3 жыл бұрын
I'm getting queries even after storing in cache. Steps unitl 7:40 followed. Why this could be? I'm using file store cache.
@free2idol1
@free2idol1 3 жыл бұрын
double check if you have already cached the query.
@8bitenial313
@8bitenial313 3 жыл бұрын
@@free2idol1 I wasn't using the cached data as return properly. Thank you.
@shaadishtiaque2084
@shaadishtiaque2084 3 жыл бұрын
Thanks for the tutorial.
@emuqatash
@emuqatash Жыл бұрын
you are perfect! thank you
@ahmedsaid7190
@ahmedsaid7190 3 жыл бұрын
Thank you very much, you are really a great man
@alembilic5614
@alembilic5614 3 жыл бұрын
Great video keep up with good work
@agentstona
@agentstona 2 жыл бұрын
fantastic great tutorial
@rism8345
@rism8345 2 жыл бұрын
Exactly what I needed. Thanks for the withoutWrapping() tip and congrats on 100k! Well deserved!
@hassanfazeel2354
@hassanfazeel2354 3 жыл бұрын
Excellent tip
@jimishukurow2286
@jimishukurow2286 3 жыл бұрын
Royal like from me, to last par of video
@gssj-o8p
@gssj-o8p Жыл бұрын
Thanks a lot for this lesson, really helped me a lot! How would you deal with routes that change result based on parameter passed in thr query string? How to cache that?
@白飯魚-k7w
@白飯魚-k7w 3 жыл бұрын
A very useful video thank you
@kickass1179
@kickass1179 3 жыл бұрын
I wish I knew how to implement cashing like this 2 years ago...thanks!
@vinitkadkol7145
@vinitkadkol7145 2 жыл бұрын
Great stuff
@Pro-jy3gp
@Pro-jy3gp Жыл бұрын
thanks for the code that what i was looking for just issue was you were hiding use Illuminate\Support\Facades\Cache;
@AhsanKhan89
@AhsanKhan89 11 ай бұрын
I have defined this rate limit to 1000 in my new Laravel 10 application but I still see Too many requests error after a few requests to the database. I searched a lot but couldn't figure out the issue yet. Are there any new changes in the Laravel 10 API using Sanctum?
@larslommen9098
@larslommen9098 3 жыл бұрын
Very useful, thanks
@sajadabbasi2268
@sajadabbasi2268 3 жыл бұрын
thanks usfull tutorials
@belaouraabdelwahab
@belaouraabdelwahab 3 жыл бұрын
Thanks a lot great video very useful
@vladyslavbondarenko4983
@vladyslavbondarenko4983 3 жыл бұрын
Cool explain!
@amgadalwattar2863
@amgadalwattar2863 2 жыл бұрын
very useful thx
@Pro-jy3gp
@Pro-jy3gp Жыл бұрын
hey got i quick question i have a API which return the user data base on user id how to cache that api now i am having a small problem after following you video i am get same repose if i change id how to solve this
@codelaravel
@codelaravel 3 жыл бұрын
Well efforts sir. Please make videos series on unit and feature testing in laravel 8 with different permission by using policy logic
@LaravelDaily
@LaravelDaily 3 жыл бұрын
I've created some content on unit/feature testing, search the channel: kzbin.info/door/TuplgOBi6tJIlesIboymGAsearch?query=testing Also, a separate course: laraveldaily.teachable.com/p/laravel-phpunit-testing-for-beginners But that content wasn't very popular, so for now not planning to dive deeper into it. You can also check out these examples: twitter.com/PovilasKorop/status/1414579559584968714
@amitdev1485
@amitdev1485 3 жыл бұрын
great videos
@dasuneranda
@dasuneranda 3 жыл бұрын
Thank you sir
@HaroldKimTV
@HaroldKimTV 3 жыл бұрын
Question. How di you cache the query in route model bindings? Same with policy Ex. function (Covid $covid, Request $req) { … }
@LaravelDaily
@LaravelDaily 3 жыл бұрын
I've googled and found this: stackoverflow.com/a/66446816
@free2idol1
@free2idol1 3 жыл бұрын
It is not worth the effort to cache the route model binding, as one of the answer from the SO pointed out by Larave Daily, it said "I cant tell how much performance improvement you get for caching one of the simplest queries a db can do (retrieve a record by primary key), but you might also try to cache the complete html contents".
@husseinh8232
@husseinh8232 2 жыл бұрын
thank you a lot for your time and effort💚❤️ I was wondering How could you show the name of attributes in functions like cache:: forget(keys:"cases"); how to show that keys as an attr back to the value
@voychoi9923
@voychoi9923 2 жыл бұрын
Thanks
@ashishchaturvedi007
@ashishchaturvedi007 3 жыл бұрын
Povilas,I want to know is there a way to use MIddleware to know if the same IP is hitting the system too many times that we stop this and show Google Captcha over the page? I want to use RateLimiter but don't know-how
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Let me google it for you. Googled "Laravel rate limit by ip", found this: hackthestuff.com/article/how-to-limit-number-of-requests-per-ip-address-in-laravel-8
@insidecampustv
@insidecampustv 3 жыл бұрын
Do you have a tutorial on how admin can suspend a user for some days, before the user will be able to login back to the website
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Two similar articles: laraveldaily.com/how-to-ban-suspend-users-in-laravel-project/ blog.quickadminpanel.com/3-ways-to-delete-user-in-laravel-block-hide-or-hard-delete/
@TheLuizSK
@TheLuizSK 3 жыл бұрын
how can i customize the rate limit message ?
@PathOfDamn
@PathOfDamn 3 жыл бұрын
So the cache can be used just like this? Do I need to set up drivers or anything such as memcached or redis? Because according to the docs it seem like I need to set something up but I don't see any set up in the video
@LaravelDaily
@LaravelDaily 3 жыл бұрын
I use default Cache driver, which is "file"
@PathOfDamn
@PathOfDamn 3 жыл бұрын
@@LaravelDaily Ok, thank you!
@xSERENKIx
@xSERENKIx 3 жыл бұрын
@Laravel Daily Thanks for your videos, really great work! But i have legacy project by laravel 5.6, laravel-telescope and ray do not work on this version. Can you advise me what to use?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Upgrade to Laravel 8. Otherwise you will have more and more things that are not working for you. Including security issues.
@xSERENKIx
@xSERENKIx 3 жыл бұрын
@@LaravelDaily Yes, I absolutely agree with you, this is my long term issue. But now I really need to work with this version. Thanks for your reply.
@JY-xv7ic
@JY-xv7ic 3 жыл бұрын
what happen with throttle middleware?
@geneartista9714
@geneartista9714 3 жыл бұрын
Does using api resource slows down your apps performance same with including observers ? Isn't it processing a lot before the data is sent to the client 😬
@LaravelDaily
@LaravelDaily 3 жыл бұрын
I haven't noticed the performance problems with those.
@ismoilkirgizov1640
@ismoilkirgizov1640 3 жыл бұрын
excellent
@lordgodgiven
@lordgodgiven 3 жыл бұрын
Hello, Thanks your video, i've a question it's possible to add a parameter such a date interval in a route resource, i'm using laravel 8. Thanks
@LaravelDaily
@LaravelDaily 3 жыл бұрын
No, Route Resource is a set of routes, not a single route, so you can't add a parameter to all of the routes.
@lordgodgiven
@lordgodgiven 3 жыл бұрын
@@LaravelDaily thanks for your replay, it's possible to store parameters in session and use it in eloquent?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Yes, similar like here: kzbin.info/www/bejne/hpLRhHiJZ9tlnc0
@lordgodgiven
@lordgodgiven 3 жыл бұрын
@@LaravelDaily thanks
@digitaluniverse9826
@digitaluniverse9826 3 жыл бұрын
Hello Mr povilas. This Is a great tutorial. Just a question though.. What if there is one to many Or many to many relationship. How we parse that in collection. Like hiding specific fields from the relationships and formatting dates etc?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
I guess this is your answer: laravel.com/docs/8.x/eloquent-resources#conditional-relationships
@Константин-л2к3э
@Константин-л2к3э Жыл бұрын
could you advise, is it reasonable to create cache on midel as the database caches all requests itself?
@LaravelDaily
@LaravelDaily Жыл бұрын
Reasonable because then you are in full control of that cache, on the application level, and may manage that cache in the code. You're not that much in control over when/how database caches things.
@yezperdk
@yezperdk 3 жыл бұрын
Related to this topic: Any chance you could make a video about versioning an API?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
I have it as one of my lessons in the course about API: laraveldaily.teachable.com/courses/how-to-create-laravel-api/lectures/17568998
@abdelwahabs.301
@abdelwahabs.301 3 жыл бұрын
Hi and thanks for this video. My question is if I want to make an API for a mobile app (using sanctum), and in the same time I will create a web app for this project, which is the best way to do that ? In order to stay in DRY principal. And let's assume that I am not comfortable with front-end framework like Vue or React and I want to use web and api routes files, how can I extract the common code used in both controllers (in web and api). I wish it's clear , thank you a lot.
@LaravelDaily
@LaravelDaily 3 жыл бұрын
It's not a question that I could answer in a short KZbin comment, will need to make a full project with a video about it. Maybe in the future.
@abdelwahabs.301
@abdelwahabs.301 3 жыл бұрын
@@LaravelDaily yes it will be good, I appreciate thanks
@thelostrider1
@thelostrider1 3 жыл бұрын
Nicee!
@L-A-O-S
@L-A-O-S 3 жыл бұрын
just in time)
@L-A-O-S
@L-A-O-S 3 жыл бұрын
like a Swiss watch.
@menma977
@menma977 3 жыл бұрын
You have any tutorial to make api public key ? Im curious..
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Sorry I don't understand what exactly do you mean by "api public key". Key for what? For what type of usage?
@menma977
@menma977 3 жыл бұрын
@@LaravelDaily such as websites that provide api tokens to be accessed by other users to build their own applications . sorry if my explanation is confusing
@LaravelDaily
@LaravelDaily 3 жыл бұрын
Ok I understand now. Well, I would use something like this: laravel.com/docs/8.x/sanctum#api-token-authentication
@menma977
@menma977 3 жыл бұрын
@@LaravelDaily does that mean it's only separated by the name of the token itself, sorry because I'm just about to try Sanctum because before I always used a passport. and in your course do you teach to make laravel pusher ? , because I've tried to use laravel pusher. to take care of it takes extra time maybe because my coding is not correct. by the way thank you for the response sir
@LaravelDaily
@LaravelDaily 3 жыл бұрын
No, I don't have courses about Pusher yet. And for Sanctum, this is not a question I can answer in a short comment, please try it out yourself.
@iochizna1568
@iochizna1568 3 жыл бұрын
Thanks for the tutorial can you do a tutorial " if a user want to access there dashboard they would provide 4 digit pincode before they can access there dashboard"
@LaravelDaily
@LaravelDaily 3 жыл бұрын
It's a very edge case. In very rare case you change email/password authentication to something like 4-digit pincode. Not planning to do a tutorial for such rare case.
@mamangboi9303
@mamangboi9303 3 жыл бұрын
This usefull
@maximilianominetto524
@maximilianominetto524 3 жыл бұрын
How to customize the message of rate limit?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
From the official docs: RateLimiter::for('global', function (Request $request) { return Limit::perMinute(1000)->response(function () { return response('Custom response...', 429); }); }); laravel.com/docs/8.x/routing#defining-rate-limiters
@maximilianominetto524
@maximilianominetto524 3 жыл бұрын
@@LaravelDaily Thanks, it wasn't difficult.
@webcodingoprogrammingtips2090
@webcodingoprogrammingtips2090 3 жыл бұрын
Great stats - 945 views, 106 likes, 0 dislikes!
@dsdigitalcompany4004
@dsdigitalcompany4004 2 жыл бұрын
Waw 😍🤤
@akshaygadekar9926
@akshaygadekar9926 3 жыл бұрын
Won't it be better to put observer in model itself, as putting it in service provider boots it for every unnecessary request
@shadmehrbz3931
@shadmehrbz3931 3 ай бұрын
Greatttt
@fatkur
@fatkur 2 жыл бұрын
cool
@TariqSajid
@TariqSajid 3 жыл бұрын
can you please make tutorial on how to secure communicate between two micro services ?
@LaravelDaily
@LaravelDaily 3 жыл бұрын
I don't actively work with micro services, so can't advise on that.
@SaywanGanji
@SaywanGanji 2 жыл бұрын
that good
@edhamrabuan8988
@edhamrabuan8988 3 жыл бұрын
Never learn this things in college🤣
Junior Code Review: Laravel Routes, Middleware, Validation and more
19:57
Exceptions in Laravel: Why/How to Use and Create Your Own
12:18
Laravel Daily
Рет қаралды 89 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
小丑教训坏蛋 #小丑 #天使 #shorts
00:49
好人小丑
Рет қаралды 54 МЛН
Laravel + Livewire todo app (and so much more)
16:41
Aaron Francis
Рет қаралды 52 М.
What’s Up with Laravel? It’s Everywhere, and Here’s Why!
6:22
From Laravel Blade to Vue.js + API [Live-coding Example]
22:28
Laravel Daily
Рет қаралды 169 М.
Laravel Security: Top 7 Mistakes Developers Make
11:16
Laravel Daily
Рет қаралды 87 М.
Good APIs Vs Bad APIs: 7 Tips for API Design
5:48
ByteByteGo
Рет қаралды 252 М.
Laravel Roles and Permissions: All CORE Things You Need To Know
16:32
Laravel Daily
Рет қаралды 227 М.
Laravel Gems - Pipelines 💎
15:21
Laravel
Рет қаралды 9 М.
Faster Eloquent: Avoid Accessors with Foreach
9:35
Laravel Daily
Рет қаралды 54 М.
Laravel Octane: supercharge your Laravel applications
8:34
Aaron Francis
Рет қаралды 50 М.
Writing My Own Database From Scratch
42:00
Tony Saro
Рет қаралды 261 М.
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН