How to Build a Laravel Project with Composer in Seconds

laravel composer

One command: $ composer create-project laravel/laravel my-app $ cd my-app && php artisan serve That produced Laravel 13.25.0 here, took 10.3 seconds with a warm Composer cache, and installed 76 packages plus 33 dev packages into an 86 MB vendor/. It also writes .env, generates an APP_KEY, and creates database/database.sqlite — so php artisan serve … Read more

Quick Guide: How to Check Your Laravel Version Easily

how to check laravel version

Run php artisan –version in the project root. That prints the framework version your application is actually booting: $ php artisan –version Laravel Framework 13.25.0 Three other methods give the same answer from different sources, and they fail in different situations, which is the part that matters: $ composer show laravel/framework | grep -E ‘^(versions|released)’ … Read more

Laravel Flash Message: A Developer’s Guide to Better UX

laravel flash message

Set the message on the redirect, read it in the view: // controller return redirect(‘/profile’)->with(‘status’, ‘Profile updated.’); // resources/views/profile.blade.php @if (session(‘status’)) <div class=”alert”>{{ session(‘status’) }}</div> @endif redirect()->with(‘key’, $value) and session()->flash(‘key’, $value) do the same thing — RedirectResponse::with() calls flash() internally. Use the first when you are redirecting, the second when you are not. “Survives exactly … Read more

How to Use AJAX with Laravel (Easy Examples)

laravel ajax

An Ajax POST to a Laravel route in the web middleware group fails with HTTP 419 “Page Expired” when the request carries no valid CSRF token. Send the token as an X-CSRF-TOKEN header (read it from <meta name=”csrf-token” content=”{{ csrf_token() }}”>) or as a _token field in the body, and the same request returns 200. … Read more

Laravel Seeder: Best Practices & HOW-TO Examples

laravel seeder

Seeders and factories are two different things. A factory (database/factories/UserFactory.php) defines what a fake record looks like. A seeder (database/seeders/DatabaseSeeder.php) decides which factories run, in what order, and with what data. The bug that actually bites people lives in the ordering, not in either piece alone. The default seeder, run for real A fresh Laravel … Read more

Learn Many-to-Many Relationships in Laravel Easily

laravel many to many

A many-to-many relationship is two belongsToMany declarations and one pivot table. Laravel will find the pivot table without configuration if it is named after the two models in singular snake_case, in alphabetical order. That last clause is where most setups go wrong. Asked what it expects, Laravel says: Post belongsToMany(Tag::class ) -> table post_tag fk=post_id … Read more

Laravel ‘whereIn’ Database Query Condition Explained

laravel wherein

whereIn compiles to a SQL IN list with one bound placeholder per array element. You can see exactly what it builds with toSql() and getBindings(), and you should, because two of its behaviours will surprise you: $q = DB::table(‘orders’)->whereIn(‘status’, [‘pending’, ‘shipped’]); echo $q->toSql(); // select * from “orders” where “status” in (?, ?) echo json_encode($q->getBindings()); … Read more

Laravel Soft Delete By Example – Quick Start Guide

laravel soft delete

Add the SoftDeletes trait to a model and a deleted_at column to its table, and delete() stops removing rows — it writes a timestamp and Laravel adds where deleted_at is null to every query the model makes: Author::query() select * from “authors” where “authors”.”deleted_at” is null withTrashed() select * from “authors” onlyTrashed() select * from … Read more

Laravel 13 Unit Testing Examples: HTTP Tests and Mocking

Laravel PHP framework logo

A new Laravel 13 app already has a working test suite: PHPUnit 12, an in-memory SQLite database, and the testing environment, all configured before you write a line. Run it with: php artisan test # or: ./vendor/bin/phpunit Worth knowing before you trust that suite: the tests run on SQLite while production almost certainly does not, … Read more

Laravel – How to send mail using Amazon SES

Laravel PHP framework logo

To send mail through Amazon SES on Laravel 13, install the AWS SDK, set MAIL_MAILER=ses, and put your AWS credentials in .env. There is no SMTP host, port, username, or password involved — the ses transport calls the AWS API directly: composer require aws/aws-sdk-php MAIL_MAILER=ses MAIL_FROM_ADDRESS=”you@yourdomain.com” MAIL_FROM_NAME=”${APP_NAME}” AWS_ACCESS_KEY_ID=AKIA… AWS_SECRET_ACCESS_KEY=… AWS_DEFAULT_REGION=us-east-1 Two things sink most setups … Read more

Laravel vs Django in 2026: Versions, Support, ORM and Admin

Programming code on a screen

Pick the one your team already writes. Both are current, both publish support dates you can plan against, and neither is faster than the other in any sense this page is willing to assert. What does differ, concretely: Django ships an admin interface and Laravel does not, and the two projects have opposite release philosophies. … Read more

Generate PDFs in Laravel 13 with DomPDF: Setup and Security

Generating a PDF in Laravel with DomPDF

Install the package and use the facade. That is the whole setup on Laravel 13 — there is no config/app.php step: composer require barryvdh/laravel-dompdf use Barryvdh\DomPDF\Facade\Pdf; return Pdf::loadView(‘pdf.invoice’, $data) ->setPaper(‘a4’, ‘portrait’) ->download(‘invoice-1042.pdf’); What I did and did not run: the composer require above was never executed and no PDF was generated. The package facts below … Read more

Laravel Forge: Introduction to Server Deployment and Automation

laravel forge

Laravel Forge is a server-management and deployment dashboard: you point it at a server, and it installs and configures Nginx, PHP, MySQL/Postgres, Redis, SSL, cron, and queue workers, then handles zero-downtime deploys from Git. It does not host anything itself in the traditional sense — per Forge’s own FAQ, fetched today from laravel.com/forge: “Do I … Read more

Laravel Faker: Generate Fake Data Easily (with Examples)

Laravel Faker generating fake data

Faker is already installed in a new Laravel app, under the name fakerphp/faker, and you reach it through the fake() helper: $name = fake()->name(); $email = fake()->unique()->safeEmail(); $year = fake()->numberBetween(1900, 2026); Do not run composer require fzaninotto/faker. Packagist reports that package as abandoned, its last release was v1.9.2 on 2020-12-11, and its GitHub repository is … Read more

Build a CI Pipeline for Laravel Using Jenkins

laravel php

Put this Jenkinsfile in the repository root. It never touches a real database: the test suite runs against SQLite in memory, which the default Laravel phpunit.xml already configures, and the migrate step is deliberately absent. pipeline { agent any environment { APP_ENV = ‘testing’ DB_CONNECTION = ‘sqlite’ DB_DATABASE = ‘:memory:’ COMPOSER_NO_INTERACTION = ‘1’ } stages … Read more

Set Up Laravel on Docker in MacOS: A Complete Guide

Laravel PHP framework logo

Use Laravel Sail rather than a hand-written Dockerfile — but install it deliberately, because a fresh Laravel app no longer ships with it. laravel new my-app # or: composer create-project laravel/laravel my-app cd my-app composer require laravel/sail –dev php artisan sail:install –with=mysql ./vendor/bin/sail up -d The hand-written Dockerfile and docker-compose.yml described below are now broken … Read more