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
php vendor/bin/pint
3. Give up on this abstraction you're about to write because it's probably too early. ✅ I can see you coming with your repository classes! Focus on testing instead.
4. Break down those one-liners. They're indigestible for your colleagues and your future self. Opting for simplicity whenever possible is smart. ✅
5. If you're missing some migrations, make sure the project's database can be set up without errors. ✅
php artisan schema:dump --prune
6. Leverage seeders and provide randomly generated data. ✅ Don't be the person who distributes edited production entries. 👀
php artisan make:seeder UserSeeder
User::factory()->count(10)->create();
php artisan migrate:fresh --seed
7. Write a README. ✅ Explain how to:
- Set the project up.
- Where to ask for credentials.
- What are the particularities of the app.
If you're not good at this, write whatever you can in your way and ask ChatGPT to rephrase and format properly. 👍
I've taken on countless projects as a freelancer, and they could have benefited from implementing these simple tips.