GrahamCampbell/Laravel-Flysystem

Config file does not use .env

WebnetMobile opened this issue · 7 comments

Hi

Is there any reason flysystem.php is not using env()? If not, I'd like to create pull request with this feature

If people want to use the env stuff, then they can, but I don't want to make it a default. There are already serious know issues with concurrency with laravel's env system.

Thanks for the answer. Can you link to any post about concurency issue with .env?

As I now need to make dropbox working, can you please tell me how can I pass app and token parameters to flysystem directly from my code (I need these parameters to come from elsewhere so if possible, I cannot write it down to config file).

I pass app and token parameters to flysystem directly from my code

You need to actual generate these with oauth. The official dropbox for php package provides an example of how to do this.

Sorry, I wasn't clear. I got these values - that's fine. I need now to make flysystem use it but I do not want to put it in config file but pass it from code.

Thanks for the answer. Can you link to any post about concurency issue with .env?

laravel/framework#7354, and that links to more issues.

The official maintainers of phpdotenv say that it should NOT be used for production use, and was only ever intended for local testing. I'm gutted to see so many people using it so much, and more and more config files being changed to use it by default.

I need now to make flysystem use it but I do not want to put it in config file but pass it from code.

There are two ways of doing this.

  1. You can define a connection on the fly by literally setting it using laravel's config system. This feels like a dirty way to do it imo though.
  2. You can call the getFactory method on the manager class, or resolve 'flysystem.factory' or 'GrahamCampbell\Flysystem\Factories\FlysystemFactory' from the ioc, then call the make method on that factory object. You need to pass just the specific config for the connection you want to that method, ie, just the bit inside what would have gone in the config for each connection.

Flicking though my test suite may be helpful to get an understanding of the internals of this package, since there's quite a few layers. :)

https://github.com/GrahamCampbell/Laravel-Flysystem/blob/master/tests/Factories/FlysystemFactoryTest.php would be useful to read for the definition of that make method. :)