Created
September 2, 2026 15:11
-
-
Save atomjoy/55014096eff66f65f240b10b8d41cbde to your computer and use it in GitHub Desktop.
PublicDirectoryProvider Laravel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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