Laravel 5.4 (February 2017) signature features and breaking-change traps from 5.3 → 5.4. Use when writing or reviewing Laravel 5.4 code or a package constrained to 5.4.*. Covers Blade components, route model binding, middleware groups, markdown mailables, and the Elixir → Mix transition. Not for application business logic; use `dhpk-php-runtime-router` for family selection and shared Laravel routing. Output: version-specific guidance, migration traps, and verification gates.
Scanned 9/2/2026
Install to Claude Code
npx -y skills add hmj1026/dhpk --skill dhpk-laravel-5-4-notes --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Dhpk Laravel 5 4 Notes?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/hmj1026-dhpk-laravel-5-4-notes)More formats (shields.io, HTML) on the badges page.
---
name: dhpk-laravel-5-4-notes
description: 'Laravel 5.4 (February 2017) signature features and breaking-change traps from 5.3 → 5.4. Use when writing or reviewing Laravel 5.4 code or a package constrained to 5.4.*. Covers Blade components, route model binding, middleware groups, markdown mailables, and the Elixir → Mix transition. Not for application business logic; use `dhpk-php-runtime-router` for family selection and shared Laravel routing. Output: version-specific guidance, migration traps, and verification gates.'
metadata:
dhpk-invocation-class: implicit-eligible
---
# Laravel 5.4 — LTS baseline
Released February 2017. Last of the 5.x line still running on the
PHP 5.6 floor, and a heavy refactor of the frontend tooling story.
> PHP floor: 5.6.4 (use the `php-5.6` module for the language
> baseline). This is the era before strict semver — the 5.x rolling
> number did not signal breaking changes meaningfully.
## Signature features
### Blade components & slots
```blade
{{-- resources/views/components/alert.blade.php --}}
<div class="alert alert-{{ $type }}">
<div class="alert-title">{{ $title }}</div>
{{ $slot }}
</div>
{{-- consuming view --}}
@component('components.alert', ['type' => 'danger'])
@slot('title') Heads up @endslot
The payment could not be processed.
@endcomponent
```
First introduced in 5.4. `@component` / `@slot` replace the older
pattern of `@include` plus a pile of passed variables. Named slots
become variables inside the component; the body becomes `$slot`.
### Route model binding (core since 5.2)
Implicit binding landed in 5.2 and is standard in any 5.4 codebase —
included here as baseline, not a 5.4-new feature.
```php
// Implicit — type-hint the model, Laravel resolves by id
Route::get('orders/{order}', function (Order $order) {
return $order;
});
// Explicit — custom key or scoping, in RouteServiceProvider::boot()
Route::bind('order', function ($value) {
return Order::where('public_token', $value)->firstOrFail();
});
```
Override `getRouteKeyName()` on the model to bind by a column other
than the primary key.
### Middleware groups — web / api (since 5.2)
The `web` / `api` groups date to 5.2 (the `routes/api.php` split to 5.3);
shown here as the 5.4 baseline, not a 5.4-new feature.
```php
// app/Http/Kernel.php
protected $middlewareGroups = [
'web' => [/* sessions, csrf, cookies, ... */],
'api' => ['throttle:60,1', 'bindings'],
];
```
The `api` group ships throttled and stateless; the `web` group
carries session + CSRF. Route files (`routes/web.php`,
`routes/api.php`) are auto-assigned their matching group.
### Realtime facades
```php
use Facades\App\Services\PaymentGateway;
PaymentGateway::charge($order); // resolves the bound instance
```
Prefix any class with `Facades\` to call it statically without
authoring a facade class. Useful for testability without boilerplate.
### Markdown mailables
```php
public function build()
{
return $this->markdown('emails.orders.shipped')
->with(['url' => $this->order->trackingUrl()]);
}
```
```blade
@component('mail::message')
# Order Shipped
@component('mail::button', ['url' => $url]) Track @endcomponent
@endcomponent
```
Pre-styled, responsive email components rendered from Markdown +
Blade. Publish and theme via `vendor:publish --tag=laravel-mail`.
### Collection higher-order messages
```php
$users->each->markAsActive();
$orders->sum->total;
$invoices->reject->isPaid();
```
Shortcut proxies for `each`, `map`, `filter`, `reject`, `sum`, etc.
that call a method or read a property on each element.
### Laravel Dusk
Introduced in 5.4 as a separate package (`laravel/dusk`) — real
browser (ChromeDriver) end-to-end testing with an expressive API,
no Selenium standalone server required.
### Resource routes
```php
Route::resource('photos', 'PhotoController');
// index/create/store/show/edit/update/destroy in one line
```
Use `->only([...])` / `->except([...])` to trim the generated set.
## Migration traps from 5.3
### The `Input` facade is gone
```php
// 5.3 and earlier
$name = Input::get('name');
// 5.4 and later — inject the request
public function store(Request $request)
{
$name = $request->input('name');
}
```
The `Input` facade was removed. Use the injected `Request` (or the
`request()` helper). This is the single most common upgrade break.
### Frontend: Elixir → Laravel Mix (webpack)
```js
// webpack.mix.js — replaces gulpfile.js / elixir(...)
const mix = require('laravel-mix');
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css');
```
`laravel/elixir` (gulp-based) was deprecated in favour of
`laravel-mix` (webpack-based). The default `package.json` scripts
become `npm run dev` / `npm run watch` / `npm run production`. Old
`gulpfile.js` projects keep working only if you stay on the elixir
package, but new scaffolding ships Mix.
### Blade CSRF / method spoofing directives
```blade
{{-- 5.4 directives --}}
<form method="POST">
{{ csrf_field() }}
{{ method_field('PUT') }}
</form>
```
`csrf_field()` and `method_field()` helpers are the supported way to
emit hidden tokens. (The `@csrf` / `@method` Blade directives are a
later addition — see "What's missing" below.)
### `$dates` and attribute casting
```php
protected $dates = ['published_at'];
protected $casts = ['options' => 'array', 'active' => 'boolean'];
```
Date and cast handling tightened in this era; columns listed in
`$dates` become `Carbon` instances. Verify serialization after
upgrade — silently-untyped attributes that were strings may now be
objects.
### Route caching changes
`php artisan route:cache` is stricter about closures — routes with
closures cannot be cached. Move closure routes to controllers before
caching in production.
---
## What's *missing* compared to 5.5+
If reviewing a 5.4 codebase, these are the features people commonly
miss and shim:
- **No package auto-discovery** (added in 5.5) — every package's
service provider and facade must be registered by hand in
`config/app.php`. Workaround: just register them manually; that is
the expected 5.4 workflow.
- **No `apiResource()`** (added in 5.5) — use
`Route::resource('x', 'XController', ['only' => ['index','store','show','update','destroy']])`
to get the API-only subset.
- **No `@csrf` / `@method` Blade directives** (added in 5.6) — use
the `csrf_field()` / `method_field()` helper calls shown above.
- **No exception `render()` / `report()` per-exception convention**
(standardized in 5.5) — centralize handling in
`App\Exceptions\Handler` instead.
- **No `whenLoaded()` on API resources** (resources themselves
arrived 5.5) — guard relation access manually with
`$this->relationLoaded('x')`.
## When NOT to Use
Not for application business logic, and not for a project on a different
Laravel major — use the matching `laravel-N-notes`. Package-authoring
concerns (service providers, facades, testbench) live in
`dhpk-laravel-package-author`.
## Output
Framework-touching code or review notes that match Laravel 5.4's APIs
(PHP 5.6.4 floor) — flag any call that actually belongs to 5.5+ (see
"What's *missing*" above).
## Verification
- Confirm the project runs Laravel 5.4 (`php artisan --version`).
- Check the PHP 5.6.4 floor before using any 7.x syntax.
- Cross-check cited APIs against the 5.3 → 5.4 upgrade guide.
## Cross-references
- `skills/dhpk-yii1-php56-development/SKILL.md` and `skills/dhpk-php-runtime-router/SKILL.md` —
PHP 5.6 idioms valid for Laravel 5.4's PHP 5.6.4+ floor (use the
`php-5.6` module for the language baseline)
- `modules/phpunit-5.7/skills/...` — the PHPUnit major that ships
with the Laravel 5.4 testing baseline
- `skills/dhpk-laravel-6-notes/SKILL.md` — the next
major (strict semver, helper migration, lazy collections)
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!