unicodeveloper / laravel-paystack

:credit_card: :package: :moneybag: Laravel 6, 7, 8, 9, 10 and 11 Package for Paystack
https://paystack.co
MIT License
615 stars 313 forks source link

Refactor Paystack Configuration to Use env() for Environment Variables #189

Open abbeymichael opened 3 months ago

abbeymichael commented 3 months ago

This pull request refactors the Paystack Laravel package configuration to use the env() function instead of getenv() for retrieving environment variables. This change was made to resolve an issue encountered in the production environment.

Changes:

Replaced getenv calls with env() in the paystack.php configuration file to fetch environment variables.

Reason for the Change:

Issue with getenv() in Production: The original implementation using getenv() was not loading environment variables correctly in the production environment. This caused issues such as the error "URI must be a string or UriInterface," as the required configuration values were not properly retrieved.
env() for Consistency: Using env() aligns with Laravel’s recommended practices for accessing environment variables. It ensures that values are correctly loaded from the .env file and properly utilized in the application.
Configuration Caching: The env() function allows Laravel to cache configuration settings, improving performance and ensuring that environment-specific values are consistently available across different environments.

This refactor addresses the issue of environment variable loading and ensures that the Paystack configuration works reliably in both development and production environments.