laracoft's avatar

How to create missing `bootstrap/providers.php`?

I just learnt about bootstrap/providers.php here https://laravel.com/docs/12.x/providers

My Laravel 5 project was upgraded over the years to L12 now, but I don't see it.

  1. Who is suppose to create it? Developer or Laravel?
  2. If there are differences with config/app.php, who is the single source of truth?
0 likes
4 replies
Glukinho's avatar
  1. For newly created projects - Laravel creates new structure. For old projects upgraded to modern Laravel version - you should either change it yourself or stay with old structure. It is still supported for backward compatibility (but nobody knows for how long it will be, so read future upgrade notes carefully).

  2. I don't think it's a good idea to mix old and new ways in a project. Choose this or that.

tykus's avatar

If you are upgrading, try wherever possible to adopt the newer syntax; this will make future upgrades easier rather than having to remember why legacy syntax/file structures are remaining and how to work around them.

1 like
Snapey's avatar

Depending of course on how big your project is, it might not be a big change to move over by creating a new Laravel 12 project and copying models, controllers, views etc into the new structure.

The biggest change is pasting your models to the new models folder as this requires a change to the namespace on each model and in every place the model is used.

I did this with a 10 year old project recently and it took about 2 hours.

martinbean's avatar

My Laravel 5 project was upgraded over the years to L12 now

@laracoft Then you don’t create the file. That file was introduced in Laravel 11+. But older projects that have been upgraded to Laravel 11 and 12 (like yours) can continue using the existing directory structure you have as Laravel remains backwards-compatible with it. Continue registering your providers in the providers array in your config/app.php like you would before.

Please or to participate in this conversation.