CodeIgniter 4: Missing support for .env configuration
Labels: enhancement, config
Context: CodeIgniter 4 with .env-based configuration
Description:
The SDK does not detect environment variables set in .env. Developers must hardcode API keys in code, which violates best practices.
Expected:
Provide helper: Openapi::fromEnv('OPENAPI_KEY', 'OPENAPI_URL');
Impact: Reduced security and configuration portability between environments.
@francescobianco I would like to work on this as my next task.
@Seraphim200001 Great starting point! The only thing to keep in mind is to open the pull request against this branch: https://github.com/openapi/openapi-php-sdk/tree/upkeep
@francescobianco I've finished this part, but I'll wait until my previous PR is merged to ensure this new one stays clean.
I implemented a system to support environment variables across different frameworks (CodeIgniter, Symfony, Laravel, etc.). I’ve added support for the following keys:
For Client.php: OPEN_API_TOKEN OPENAPI_BASE_URL
For OauthClient.php: OPENAPI_OAUTH_USERNAME OPENAPI_OAUTH_APIKEY OPENAPI_OAUTH_TEST_URL OPENAPI_OAUTH_URL
Please let me know if there are any other places where we might need environment variable support!
Thanks to your work, we’ve identified some inconsistencies between our internal naming and the public one 🙌
We’ve prepared a naming guide to standardize everything moving forward. Could you please take a look at the following sections?
- https://github.com/openapi/openapi-naming?tab=readme-ov-file#6-php
- https://github.com/openapi/openapi-naming?tab=readme-ov-file#3-environment-variables
Your feedback would be really helpful to ensure everything is aligned. Thanks again for your contribution!
cc @Seraphim200001
@francescobianco , I will also implement the naming convention for interfaces and traits. Here are some suggestions for the naming:
Interfaces: OpenapiClientInterface (Pattern: Openapi*Interface)
Traits: OpenapiConfigurableTrait or OpenapiHasConfig / OpenapiUsesConfig (Pattern: Openapi*Trait or Openapi[Action])
What do you prefer?
I love the Openapi*Trait trait — it’s my favorite.
A special Thanks for @Seraphim200001, read your name here on the release page --> https://github.com/openapi/openapi-php-sdk/releases/tag/1.3.0