Code feed
Code worth pausing your scroll for.
Filter your feed
Community signal
ShuffleWarn When a Return Value Is Ignored
Use #[NoDiscard] when callers should not accidentally ignore an important result.
Warn When a Return Value Is Ignored
#[\NoDiscard]
function saveOrder(Order $order): bool
{
return $order->save();
}
$saved = saveOrder($order);
Route Laravel Jobs Centrally
Define the default connection and queue for a job class in one place.
Route Laravel Jobs Centrally
use App\Jobs\ProcessPodcast;
use Illuminate\Support\Facades\Queue;
Queue::route(
ProcessPodcast::class,
connection: 'redis',
queue: 'podcasts',
);
print code
print('hello world')
PHP 8.5 Pipe Operator
Pass a value through multiple functions without temporary variables or nested calls.
PHP 8.5 Pipe Operator
<?php
$title = ' PHP 8.5 Released ';
$slug = $title
|> trim(...)
|> (fn ($value) => str_replace(' ', '-', $value))
|> strtolower(...);
Perform Semantic Search with Scout
Find records by meaning instead of relying only on exact keyword matches.
Perform Semantic Search with Scout
$documents = Document::search('Laravel queue guide')
->semantic()
->where('published', true)
->get();
Pause or Resume Every Queue
Pause all Laravel queue connections during maintenance and resume them afterward.
Pause or Resume Every Queue
php artisan queue:pause --all
php artisan queue:resume --all
Build multi-type JSON schemas
Laravel 13 API example based on official Laravel documentation. Source: https://laravel.com/framework/docs/changelog#add-multi-type-union-support-to-illuminatejsonschema
Build multi-type JSON schemas
<?php
use Illuminate\JsonSchema\JsonSchema;
$identifier = JsonSchema::union([
'string',
'number',
])->nullable();
// Further reading: https://laravel.com/framework/docs/changelog#add-multi-type-union-support-to-illuminatejsonschema
Extend the new Artisan dev runner
Laravel 13 API example based on official Laravel documentation. Source: https://laravel.com/framework/docs/changelog#add-artisan-dev-command
Extend the new Artisan dev runner
<?php
use Illuminate\Foundation\Console\DevCommands;
DevCommands::artisan('reverb:start', 'reverb')->orange();
DevCommands::register(
'stripe listen --forward-to '.config('app.url'),
'stripe',
)->green();
// Start everything with: php artisan dev
// Further reading: https://laravel.com/framework/docs/changelog#add-artisan-dev-command
Inspect HTTP fake request URIs
Laravel 13 API example based on official Laravel documentation. Source: https://laravel.com/framework/docs/changelog#add-clientrequesturi
Inspect HTTP fake request URIs
<?php
use Illuminate\Http\Client\Request;
use Illuminate\Support\Facades\Http;
Http::assertSent(fn (Request $request) =>
$request->uri()->path() === '/api/users'
&& $request->uri()->query()->integer('page') === 2
);
// Further reading: https://laravel.com/framework/docs/changelog#add-clientrequesturi
Know whether a cache item was warm
Laravel 13 API example based on official Laravel documentation. Source: https://api.laravel.com/docs/13.x/Illuminate/Cache/Repository.html#method_rememberWithWarmth
Know whether a cache item was warm
<?php
use Illuminate\Support\Facades\Cache;
[$products, $warm] = Cache::rememberWithWarmth(
'products:featured',
now()->addHour(),
fn () => Product::featured()->get(),
);
return response()->json($products)
->header('X-Cache', $warm ? 'HIT' : 'MISS');
// Further reading: https://api.laravel.com/docs/13.x/Illuminate/Cache/Repository.html#method_rememberWithWarmth