🏠 Home 👤 About ⚡ Skills 💼 Portfolio 📦 Packages 📝 Blog ✉ Contact ✉ Contact Now
All Articles

Automating the Boring Parts of a Laravel Project

Every project has the same twenty minutes of setup, the same deploy steps, the same forgotten checks. Automating them once pays back on every project after.

Junaid Ali 2 min read 0 views

The work that costs you most is not the hard work. It is the twenty-minute ritual you repeat on every project and every deploy, forgetting one step roughly a third of the time.

Write Custom Artisan Commands

Anything you have done manually three times becomes a command.

php artisan make:command SyncSitemapPing

public function handle(): int
{
    Http::get('https://www.google.com/ping?sitemap=' . route('sitemap'));
    $this->info('Sitemap ping sent.');
    return self::SUCCESS;
}

Use the Scheduler for Everything Recurring

One cron entry on the server, everything else in code where it is versioned and reviewable.

Schedule::command('sitemap:ping')->weekly();
Schedule::command('backup:run')->dailyAt('02:00');
Schedule::command('queue:prune-failed --hours=168')->daily();

A Deploy Script, Not a Checklist

A checklist gets skipped under pressure. A script does not.

#!/usr/bin/env bash
set -e
php artisan down --render=errors::503
git pull origin main
composer install --no-dev --optimize-autoloader
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan queue:restart
php artisan up

The set -e matters: if the migration fails, you stop rather than caching config against a half-migrated database.

Git Hooks for the Checks You Skip

A pre-commit hook running your linter costs two seconds and prevents a class of embarrassing commits.

Seeders as Real Development Data

A seeder that produces a realistic dataset — hundreds of records, not three — means new developers are productive in a minute, and N+1 problems surface locally instead of in production.

The Payback Test

Automate anything you will do more than five times, or anything where forgetting a step causes an outage. Everything else, do by hand.

Tagged Automation Laravel DevOps Productivity
Share this article

Want this built properly?

I take on a small number of projects at a time so each one gets real attention.

WhatsApp Teams LinkedIn Facebook GitHub