Think PHP and Laravel don't scale? Think again.
OpenAI is hiring web developers like us for their main website which gets hundreds of millions of visits each DAY. 👍
Laravel developers, here's my first Livewire v3 advice.
Are you using `wire:navigate` everywhere? Improve the UX by scrolling the user back to the top of the page whenever a link is clicked. 👍
Laravel 11 is here! 🎉
4 tips for an easy update:
1. No need to hurry. Your apps won't instantly improve with Laravel 11. Remember: Laravel 10 will be updated until February 4, 2025.
2. Run "composer outdated" to see which dependencies have a new major version waiting.
3.…
Laravel best practices: the definitive guide for 2022 ✅
It's a work in progress.
The more you'll share it, the better this guide will be. I need as much feedback as possible. 💪
Are you using the new accessors and mutators in Eloquent?
Did you know the value can be cached for the duration of the request using the simple "shouldCache()" method?
Very handy when the attribute requires heavy computation (loops, database queries, etc.). 👌
#laravel
Web Artisan GPT.
Good idea or not? 🤔
Basically, it's been fed the LATEST documentation from Laravel, Livewire, and Filament. No April 2023 knowledge cutoff.
It can help you learn and build anything.
I could add Tailwind CSS and many others too. 👌
Two basic golden rules with Livewire:
1. Never forget wire:key in loops. ✅
2. Manage items in the parent component if you extracted them to a child. That way, reactivity is effortless. ✅ ($parent is your friend.)
90% of problems solved.
Here's the great news: soon, I will produce content for our beloved
@Laracasts
!
I'm going full circle here, because this is where I started learning Laravel in 2015. I'm super happy to contribute. 🙂
This single component can turn your Laravel app into something that feels like a SPA when using Livewire v3.
Combine that with the tip I shared two days ago. 👍
Keep your Laravel projects in check with my updated list of best practices. 🔥
Discover actionable tips to improve your codebase without added complexity. 👍
So, I've been bitten in the ass by some convenience method Laravel offers.
My SaaS was down for ~30 minutes yesterday because I was so tired I couldn't figure it out.
In Laravel's migrations, you can use the foreignIdFor() method to avoid setting the column's name yourself.…
Discover 20+ up-to-date Laravel best practices on my blog.
1. Use factories for fake data and testing.✅
2. Stick to the default folder structure unless forced to do otherwise. ✅
3. Use Eloquent’s strict mode to prevent performance issues and bugs.✅
Link below. 👇
7 things you can do right now to improve your Laravel codebase:
1. Write a simple test using Pest. ✅
php artisan make:test HomeTest --pest
it('works', function () {
get('/')
→assertOk();
});
2. Format all your files using Pint. ✅
composer install laravel/pint…
I always loved looking at codebases that generate value.
This is why my blog is now open-source! 🥳
I launched it almost a year ago and scaled the traffic to more than 20K monthly visits. 🚀
Link to the repository below! 👇
Don't underestimate Laravel's HTTP client convenience.
Here's how to set the timeout and even retry your request if you're dealing with an unreliable service.
Livewire v3 Coding Assistant
Coming next week on the GPT Store.
Say goodbye to outdated knowledge and hallucinations! 🔥
And expect other very useful GPTs tailored for Laravel developers…
From my experience, this is one of the best way to stabilize a legacy Laravel codebase:
1. Fix the code style. It's essential to bring some order in chaos. This requires good communication with the team, though. Because Git conflicts are a nightmare.
2. Create missing…
Laravel developers, what team are you? 💪
1. PostController
2. ListPostsController, ShowPostController, CreatePostController, StorePostController, EditPostController, UpdatePostController and DestroyPostController
Indie hackers lack ambition.
That's why most fail.
"I launched X amount of products and they all failed."
OK. Let's see:
1. A boilerplate for something they never had success with.
2. A low-effort/low-interest LLM wrapper with a subpar UI.
3. A directory site like it's the…
My blog (+20K visits/month) goes open source tomorrow.
- I cleaned up the code. ✅
- Improved the Atom feed. ✅
- Added AI-based features. ✅
- Switched to Livewire v3 + Volt. ✅
Here's a demo of me generating a teaser that encourages users to click when in the Atom feed:
Here are 6 reasons why your Laravel codebase is a pain to work with:
1. Incomplete migrations, no factories, and no seeders. You shouldn't have to rely on production data. Laravel's documentation on these matters is super simple to understand, so go for it!
2. No automatic code…
With time, most Laravel projects go to shit. 😬
After years of consulting, I noticed the same pattern and leading causes.
1. The owner only hires juniors
2. Juniors overthink everything while lacking essential knowledge
This thread will be of extreme value to you. 🔥
I wouldn’t go another way to organize tests in Laravel projects. It makes it clearer which parts of the app are tested or not. 👍
Here’s my PHPUnit configuration if you’re interested:
All this works great combined to `php artisan test --coverage`. ✅
Avoid breaking things on your Laravel app: ⚠️
Livewire dynamically generates its JavaScript file.
Therefore, make sure you prevent Nginx from interfering whenever you do custom stuff on static assets (like setting the Cache-Control header).
I'm back on the market for a job and I'd appreciate reposts, thanks! 💪
I'm full-stack Laravel with 10+ years of experience.
I have many strings to my bow, making me valuable to growing startups.
Remote or London area (if you can sponsor a visa).
The new version of my blog is live! 🎉
It's using Laravel, it's ultra fast thanks to Livewire v3, it looks good, it has great content, it will unlock new growth opportunities, and…
It's still open source! 🔥
I think my 20,000+ readers will love it, and you too!
Some Laravel developers started using DTOs instead of custom form requests.
Did you? Because I'm thinking about it. 🤔
Spatie even has a package for that (spatie/laravel-data). 👌
For anyone having a 404 after installing Laravel Pulse, here's a potential solution:
You may have a wildcard highjacking the `pulse` route.
The fix is simple, but good luck writing that by yourself. Thank you Copilot! (More details below.)
We have absolutely no idea when PHP 9.0 will be released.
But who cares? Let's start ranking for it now (and I noticed people are already searching for 9.0).
When I started learning web development in 2006:
- IE6 ruled the world.
- PHP 4 was widely used.
- We used "DHTML" to add falling snow.
Some would argue that it was a simpler era. But I think it's debatable.
Confession: I haven't used a GraphQL API even once.
I have no idea how they work or how to build them.
I'm not against it, I just didn't have any valid use case for now. 🤷♂️
Best Laravel tips for enterprise projects:
- Stick to the default structure ✓
- Write tests to help your team change code safely ✓
- Defer as much work as possible to Laravel because your talent is required elsewhere ✓
Breaking any of these should require solid arguments.
This morning, I noticed someone tried to inject SQL into the wildcard route of my blog (/{post:slug}) because the error messages where reported on my Sentry.
Here's the query that resulted (the blog looks for redirection rules first):
select * from `redirects` where `from`…
Facades in Laravel in a nutshell:
1. You → Facade::foo() → __callStatic() → Container → $instance→foo()
2. When called without import, that's thanks to class_alias().
That's it. No wizardry. No true static call.
It's just clever and have proven records of helping. 🙂
Barely standing on my feet with my eyes open. 🥱
Worked all weekend with almost no sleep last night and had to catch a flight for 7 AM.
It was worth it, though. The blog has great content, plenty of traffic from Google and looks awesome. 👍
Earlier today, I asked people about their favorite transactional email service.
Here's the list from the replies I got, including some I found by myself (I'm still undecided by the way, haha):
- Resend
- Postmark
- SendGrid
- Mailcoach (It's from Spatie, and they also handle…
Here are some breathtaking changes coming to Laravel 11. 🔥
1. A slimmer app skeleton thanks to a minimal app directory; no config files, no visible middleware, no service provider besides AppServiceProvider, etc. Even ./artisan and ./public/index.php have been cleaned up!
2.…
Filament v3 is a blessing for the Laravel community. 👌
I feel like the possibilities are endless and I only scratched the surface. 🤯
For now, I'm just revamping the admin of my blog, but I will certainly explore more of it.
I realized something that could change the lives of thousands of developers:
ChatGPT can write REST APIs documentation now. 🤯
Here is the basic prompt with minimal information.
I just showed the Laravel code.
The parameters are inferred. You can just focus on coding now.
Laravel 11 is coming soon.
3 things you can do for a painless upgrade:
1. Don't rush it. Laravel 11 won't suddenly make your apps better.
2. Make sure the third party packages you use support it. (Go on Packagist and check for ^11.0 version constraint.)
3. Write tests. Lots…
One of the best things I discovered recently in Laravel is the request()→routeIs() method.
It supports infinite parameters and wildcard names so you can do request()→routeIs('foo.*', 'bar.*')
My blog's revamp is almost done. It's going to be great with Laravel, Livewire v3, Volt, and Filament. Also fast as hell! 🔥
And remember, it's open source. Checkout the develop branch and see it for yourself. The code is a hell lot better, while still simple and tested.
By the way, did you know that my Laravel-based blog is open source?
For a reminder, it's growing and generates more than 30,000 monthly visits. 💪 And that's something you can see for yourself because the analytics dashboard is publicly accessible.
I released its source code in…
Laravel developers.
Artificial intelligence is just a REST API call away.
No need to train a model with a gazillion amounts of data using thousands of GPUs.
How mind-blowing is it that? 🤯
Here's how to create a spam detection system:
Laracon 2023 started, and you better believe I'm ready to write tutorials for all the new things that will be announced. 💪
- Laravel 11 Preview (I already wrote about this, though)
- Laravel Folio
- Laravel Herd
- Laravel Prompts
- Laravel Volt
- Livewire 3
Let's do this! 🚀
Laravel developers, here are 3 crucial Livewire tips (+ 1 bonus):
1. Always use wire:key in loops. ✅
2. Sub components also need wire:key when inside a loop, no matter how nested! ✅
3. When you forget wire:key somewhere, Livewire is actually telling you! ✅
Open your…
Who needs a reminder about how Facades work in Laravel?
You → Facade::foo() → __callStatic() → Container → $instance→foo()
So yeah, no true static call, and perfectly testable. ✅
And did you know why Facades also work when not imported? For instance:
Cache::flush();
It…
I already wrote an article showing you how to use Bun in any Laravel project.
You will see how straightforward it is to replace NPM, pnpm, or Yarn.
Link below! 👇
Laravel has tons of abstractions to help you keep your code structured.
Why not leverage them before you create yours? Try hitting the framework's limits first.
Examples:
- API resources
- Events
- Factories
- Form Requests
- Listeners
- Mailables
- Middleware
- Notifications
-…
DDD is overkill for most Laravel projects.
A good way to keep them organized is to leverage Laravel's features and magic. 🔥
1. Use policies
2. Use custom requests
3. Extract logic to services
4. Use single-action controllers
5. Register your services in the container
👇
GPT-4 strikes again. 🔥
I managed to automatize one of the most annoying things Laravel developers have to do.
Internationalizing a project by wrapping up strings in the __() helper across dozens of Blade templates.
What a relief! 😮💨
Livewire v3 is almost there and I'm super hyped! 👌
Keeping Laravel projects simple is not possible by adding Vue.js or, even worse, React. Livewire fixes this issue.
What's your favorite feature of v3? To me, it's the persist directive. 😍
Using PHP, let’s build the basis for an automated job offers aggregator powered by AI.
We’ll be using the OpenAI PHP client from
@enunomaduro
,
@gehrisandro
and Mantas Smilinskas.
🤖
Another week, another call for freelance work. 👋
I still have open slots for Laravel-related gigs.
If you are serious and have an immediate need for a veteran full-stack Laravel developer, drop me a DM! 💪
Anything that boosts this post is appreciated! 🙏
I just wrote a super informative piece about PHP 8.3's new Override attribute.
If you didn't understand it before, there's no way you still won't after reading my article.
Link below, enjoy! 👇
For web apps, unit tests are mostly useless. ✋
It's easier to write them, they're fast, and it feels productive. But code doesn't run as isolated pieces in production.
Write feature tests!
I guarantee you'll have less regressions if you start now. 👍
Laravel developer: "It takes time to write tests."
The test:
it('works')
→get('/foo')
→assertOk();
At some point, admit you don't want to get out of your comfort zone. 🤷♂️
Great feature on Laravel's router: the missing() method.
It lets you customize how your app behaves on a 404.
Usually, the default behavior is good. But in my case, I can redirect to the index on a missing resource, which is a better UX for authenticated users.
How do you generate URLs in your Laravel applications? 🤔
1. I use route names.
2. I like to suffer; I use route actions.
3. I'm a sociopath; I use the url() helper.
4. I'm a psychopath; I hard-code the URLs.
OK. Serious question. Are you using Docker or Laravel Valet?
Aren't you bothered to constantly manage your containers and consume precious resources?
(Yes, you can manage multiple versions of PHP and databases with Laravel Valet through Homebrew.)
Every time I share a code snippet image, I generate it using a tool I made but never released.
It's basically a GitHub Gist client with images as a bonus for social media. 👌
Writing tests on big Laravel apps is hard. 😅
But here's a rock solid strategy to help you build momentum.
1. Write a test for your home page. ✅
Then, repeat for other GET routes; it should be easy and it's better than nothing.
I'd take a regular job again and give everything I have if:
→ It's in the UK (around London or remote). 🇬🇧
→ It's all in with Laravel. 🔥
→ Equity is an option and it pays dividends (unless reinvesting for growth is necessary). 📈
If that's you, let's chat!
Did you know there was an extension to the official Standard PHP Library that brought Enums to PHP 7? 🤯
Or maybe you don't even know what Enums are yet? 🤔
Since developers highly research the topic on Google, I wrote an extensive blog post about Enums on my blog. 🔥👇
Just woke up to a video of Povilas reviewing one of my articles about testing best practices in Laravel.
This is GREAT. The feedback gave me ideas on how I could improve it!
Laravel tip: the behavior of implicit model binding is easily customizable.
For instance, redirect to another route instead of a 404 when a model is not found. ✅
Important Laravel tip:
Whenever you assert that a job has been dispatched, make sure it can be serialized and restored. ✅
Without this, you still have a door open for failure in production.
(Available in Laravel 10.21.0+.)
@jmwilt21
Don't want to sound like a douche, so please don't take it wrong, but the need for a touch screen and the multitasking issues are probably a lack of mastery of keyboard/trackpad shortcuts. Spaces are great too.
And Apple designed a feature you may want to try: Mission Control…
Think Tailwind CSS doesn't scale?
This is because you are using your tools wrong.
Leverage your templating engine right (Laravel Blade in my case), and you will change your mind, I guarantee it.
Having a single source of truth makes it way easier for your team. 👍
Getting started with PHP? Don't wait to pick Laravel.
Many will recommend you master PHP first, but I disagree.
Using a framework, you'll reach your goals quicker and stay motivated.💪
You'll also witness what real-world PHP is and learn a ton without noticing it.
By the way, did I tell you that we are taking the blog of Laracasts to the next level? 🚀
It's currently being revamped, and I'm writing tons of Laravel-related content for it. It's going to be great. 👍
Laravel developers, which coding style do you prefer?
1. Looks neat, but autocompletion doesn't work.
2. More verbose, but it's autocompletion-friendly.
Earlier today I talked about two golden rules in Livewire.
One of them is to always handle list management in the parent. 👈
Some didn't fully grasp what I meant.
Therefore, I recorded myself showing you live on my blog! 🔥
(This will help me get better at screencasting and…
My package to generate documentation just by reading the code with GPT is going well.
Here are some details and possibilities:
- Only the relevant code is sent to OpenAI; no worries.
- The best thing is that you can run this each time your API is updated (CI is also possible).…