NicklasWallgren / PokemonGoAPI-PHP

Pokemon Go API PHP library
BSD 2-Clause "Simplified" License
130 stars 51 forks source link

Refactor authentication managers to expose config object and add default .env file location #119

Closed WisdomSky closed 8 years ago

WisdomSky commented 8 years ago

Since we pass a Config instance into the Manager Factory, maybe it just makes sense to save the config information used to instantiate the manager.

This may allow us to define more things in the config object and access it later on from the manager instance using getConfig() method.

An example is the implementation for default .env path to where the app should look for the .env path if there is no path explicitly passed to the ApplicationKernel.

This will also answer the question The configuration for the .env file path goes to the ApplicationKernel constructor while the configuration for the user credentials goes to the Config Object. But why? Shouldn't them be kept in a single place?.


These commits also include implementation for default .env location. If the user doesn't specify any path to where the app will look for the .env file, the app will attempt to look for it on the parent directories (up to 4 levels). This is really helpful if you are using a framework like laravel and already have an .env file at the base path. If no .env file is found any of the parent directories, it will not be loaded.

For backward compatibility, the user can still pass a second argument to the ApplicationKernel constructor to specify the env file location. (check the examples/AuthenticationExample.php)

111

NicklasWallgren commented 8 years ago

I'm planning to remove the .env file altogether in a upcoming release.

Nice contribution thought :)

WisdomSky commented 8 years ago

sure no problem. :)