smadeira / ministry-platform-api

Ministry Platform REST API wrapper
MIT License
10 stars 7 forks source link

Updated to latest version 3.1.4 (from 3.1.3) and got Fatal Error around Environment variables and Oauth #9

Open bzerangue opened 4 years ago

bzerangue commented 4 years ago

Today, I updated to latest version 3.1.4 (from 3.1.3) of the API and it broke everything.

First, I got this Fatal Error...

<br />
<b>Fatal error</b>:  Uncaught TypeError: Argument 1 passed to Dotenv\Dotenv::create() must be an instance of Dotenv\Repository\RepositoryInterface, string given, called in /Users/User/Sites/Dev/MP-Dev/MP-API-PHP/index.php on line 8 and defined in /Users/User/Sites/Dev/MP-Dev/MP-API-PHP/vendor/vlucas/phpdotenv/src/Dotenv.php:81
Stack trace:
#0 /Users/User/Sites/Dev/MP-Dev/MP-API-PHP/index.php(8): Dotenv\Dotenv::create('/Users/User/Site...')
#1 {main}
  thrown in <b>/Users/User/Sites/Dev/MP-Dev/MP-API-PHP/vendor/vlucas/phpdotenv/src/Dotenv.php</b> on line <b>81</b><br />

And then had to update Dotenv\Dotenv::create() to either createImmutable or createMutable for that type error to go away.

And then I got the following Fatal Error...

<br />
<b>Fatal error</b>:  Uncaught InvalidArgumentException: URI must be a string or UriInterface in /Users/User/Sites/Dev/MP-Dev/MP-API-PHP-Test/vendor/guzzlehttp/psr7/src/functions.php:62
Stack trace:
#0 /Users/User/Sites/Dev/MP-Dev/MP-API-PHP-Test/vendor/guzzlehttp/guzzle/src/Client.php(211): GuzzleHttp\Psr7\uri_for(false)
#1 /Users/User/Sites/Dev/MP-Dev/MP-API-PHP-Test/vendor/guzzlehttp/guzzle/src/Client.php(154): GuzzleHttp\Client-&gt;buildUri(false, Array)
#2 /Users/User/Sites/Dev/MP-Dev/MP-API-PHP-Test/vendor/guzzlehttp/guzzle/src/Client.php(182): GuzzleHttp\Client-&gt;requestAsync('get', false, Array)
#3 /Users/User/Sites/Dev/MP-Dev/MP-API-PHP-Test/vendor/guzzlehttp/guzzle/src/Client.php(95): GuzzleHttp\Client-&gt;request('get', false, Array)
#4 /Users/User/Sites/Dev/MP-Dev/MP-API-PHP-Test/vendor/smadeira/ministry-platform-api/src/OAuth/oAuthBase.php(105): GuzzleHttp\Client-&gt;__call('get', Array)
#5 /Users/User/Sites/Dev/MP-Dev/MP-API-PHP-Test/vendor/smadeira/ministry-platform-api/src/OAuth/oAuthClientCredentials.php(65): MinistryPlatformAPI\O in <b>/Users/User/Sites/Dev/MP-Dev/MP-API-PHP-Test/vendor/guzzlehttp/psr7/src/functions.php</b> on line <b>62</b><br />
smadeira commented 4 years ago

Sorry about that. I will look at it and get it fixed. My first guess is adding the ability dotenv 5 support broke something along the way. That fatal error is usually because it didn't read a URL from the .env file. That would be consistent with the dotenv issues.

I am reverting to 3.1.3 and pushing it up as 3.1.5. That seems to be the quickest way to get rid of the change.

bzerangue commented 4 years ago

@smadeira - Thank you so much!

smadeira commented 4 years ago

I think I have it working now to support phpdotenv 3.x (part of Laravel 5 and 6) and phpdotenv 4.x (part of Laravel 7.) I'm not a github/packagist wizard but if you spec 3.x in your composer.json file for the ol stuff and 4.x for the new stuff, you should get what you need. I tried it on two separate projects of mine and both were getting the correct files.