Skip to content

Instantly share code, notes, and snippets.

@atomjoy
Created September 2, 2026 15:11
Show Gist options
  • Select an option

  • Save atomjoy/55014096eff66f65f240b10b8d41cbde to your computer and use it in GitHub Desktop.

Select an option

Save atomjoy/55014096eff66f65f240b10b8d41cbde to your computer and use it in GitHub Desktop.
PublicDirectoryProvider Laravel
<?php
// php artisan storage:link
namespace App\Providers;
use Carbon\CarbonImmutable;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\ServiceProvider;
use Illuminate\Validation\Rules\Password;
class PublicDirectoryProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
// Create symlinks
config(['filesystems.links' => [
public_path('storage') => storage_path('app/public'),
base_path('public_html') => base_path('public')
]]);
// Change directory
$this->app->bind('path.public', function () {
return base_path('public_html');
});
}
/**
* Bootstrap services.
*/
public function boot(): void
{
// $this->configureProduction();
}
/**
* Production defaults
*/
public function configureProduction(): void
{
Date::use(CarbonImmutable::class);
DB::prohibitDestructiveCommands(
app()->isProduction(),
);
Password::defaults(fn (): ?Password => app()->isProduction()
? Password::min(12)
->mixedCase()
->letters()
->numbers()
->symbols()
->uncompromised()
: null,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment