Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Daryl Carr
Daryl Carr
18,318 Points

How to add code to github that uses private info like email address and password for phpmailer?

Is there a way to hide this? I want to be able to to push my projects to github to show my php code but I'm not sure how I go about changing these details but keeping them in my local so that I can test etc...

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

You can use environment variables in your shell/system and read them in you PHP script through $_ENV like you would $_GET or $_POST. That way they aren't stored anywhere but your local system. This is how many web apps deal with secrets like database credentials and such so they are kept out of the code.

Daryl Carr
Daryl Carr
18,318 Points

Great, thanks for the help!