Never store sensitive credentials in your code again – PHP dotenv

5. February 2020
.SHARE

Table of Contents

PHP dotenv loads environment variables from .env to getenv()$_ENV and $_SERVER automagically.

You should never store sensitive credentials in your code. Anything that is likely to change between deployment environments – such as database credentials or credentials for 3rd party services – should be extracted from the code into environment variables.

Add your application configuration to a .env file in the root of your project. Make sure the .env file is added to your .gitignore so it is not being checked-in.

DEFINE

LOAD

ACCESS

GitHub

Enjoy coding and be secure …

Let’s Talk!

Looking for a reliable partner to bring your project to the next level? Whether it’s development, design, security, or ongoing support—I’d love to chat and see how I can help.

Get in touch,
and let’s create something amazing together!

RELATED POSTS

Gutenberg Grids & Timber ++ Some CSS Grid Magic!

A grid mystery Somehow the Grids Layout Builder for Gutenberg ist not pushing styles to the footer within a Timber theme. At least not for me. Somehow the wp_footer action within the Grids plugin is not being executed and no grid styles are added to the footer. I am not getting any errors, but will have to investigate some […]

Optimizing Typekit font loading

When loading web-fonts, we often see a brief un-styled moment before the browser applies the actual font. Gladly Typekit and also Google Web Fonts provide an option around that. Both are using WebFont Loaders to help handle those brief moments. TypeKit Webfont Loader Example (function(d) { var config = { kitId: ‘***’ , // Your […]

Is the classic product dead ?

As a developer we daily look for oportunities to sell ourselfs and our products. We seek new frontiers by advancing our skills and constantly looking at new technologies. We work on new innovative products, that we hope will conquer the world. The question always remains, are we actually producing and advancing for our clients? Do […]

Alexander

I am a full-stack developer. My expertise include:

  • Server, Network and Hosting Environments
  • Data Modeling / Import / Export
  • Business Logic
  • API Layer / Action layer / MVC
  • User Interfaces
  • User Experience
  • Understand what the customer and the business needs


I have a deep passion for programming, design, and server architecture—each of these fuels my creativity, and I wouldn’t feel complete without them.

With a broad range of interests, I’m always exploring new technologies and expanding my knowledge wherever needed. The tech world evolves rapidly, and I love staying ahead by embracing the latest innovations.

Beyond technology, I value peace and surround myself with like-minded individuals.

I firmly believe in the principle: Help others, and help will find its way back to you when you need it.