openapi-php-sdk icon indicating copy to clipboard operation
openapi-php-sdk copied to clipboard

CodeIgniter 4: Missing support for .env configuration

Open francescobianco opened this issue 1 year ago • 7 comments

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 avatar Nov 09 '25 16:11 francescobianco

@francescobianco I would like to work on this as my next task.

Seraphim200001 avatar Apr 03 '26 16:04 Seraphim200001

@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 avatar Apr 07 '26 12:04 francescobianco

@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!

Seraphim200001 avatar Apr 09 '26 07:04 Seraphim200001

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 avatar Apr 14 '26 10:04 francescobianco

@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?

Seraphim200001 avatar Apr 14 '26 11:04 Seraphim200001

I love the Openapi*Trait trait — it’s my favorite.

francescobianco avatar Apr 28 '26 13:04 francescobianco

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

francescobianco avatar May 08 '26 16:05 francescobianco