Use $user->created_at->translatedFormat('Y - F')
instead of `$user->created_at->format('Y - F')
`
// php file
// note: don't use format() but translatedFormat() instead
echo $user->created_at->translatedFormat('Y - F'); // 2025 - februari
When needed, you might want to add the locale to your docker image as well
// file: Dockerfile
RUN apt update && apt-get install -y locales && \
sed -i '/nl_NL.UTF-8/s/^# //g' /etc/locale.gen && \
locale-gen
I almost always install the following packages on a new laravel project.
What about you?
composer require \
"lab404/laravel-impersonate" \
"livewire/livewire" \
"lorisleiva/laravel-actions" \
"sentry/sentry" \
"sentry/sentry-laravel" \
"spatie/laravel-data" \
"spatie/laravel-login-link" \
"spatie/laravel-permission" \
"spatie/laravel-ray" \
"spatie/laravel-slack-alerts"
And for development
composer require --dev \
"barryvdh/laravel-debugbar" \
"driftingly/rector-laravel" \
"fakerphp/faker" \
"larastan/larastan" \
"laravel/pint" \
"pestphp/pest" \
"pestphp/pest-plugin-laravel" \
"phpstan/phpstan" \
"rector/rector" \
"spatie/laravel-ignition" \
"xammie/mailbook"
Open your settings in PHPStorm and go to Tools > File Watchers
Add a new Custom File Watcher and use the following information:
Name: pint
File type: PHP
Program: $ProjectFileDir$/vendor/bin/pint
Arguments: $FileRelativePath$
Output paths to refresh: $FileRelativePath$
Working directory: $ProjectFileDir$
Add the full url, environment and the used HTTP method to the context of your exception so it gets logged with all needed information:
<?php
// file: bootstrap/app.php
return Application::configure(basePath: dirname(__DIR__))
...
->withExceptions(function (Exceptions $exceptions): void {
$exceptions->context(fn () => [
'app' => config('app.name'),
'url' => url()->full(),
'environment' => app()->environment(),
'method' => request()->getMethod(),
]);
})->create();
props to @_newtonjob this tweet
<?php
// In laravel 10
// file app/Exceptions/Handler.php
class Handler extends ExceptionHandler
{
public function register(): void
{
//
}
public function context()
{
return array_merge(parent::context(), [
'app' => config('app.name'),
'url' => url()->full(),
'environment' => app()->environment(),
'method' => request()->getMethod(),
]);
}
}