11 Replies - 295 Views - Last Post: 02 January 2018 - 02:14 AM Rate Topic: -----

#1 [email protected]  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 57
  • Joined: 24-February 15

php file and github

Posted 30 December 2017 - 05:24 AM

In my config.php I have my database info, if I put that on Github to share, people can see my login info. What can I do about it, so people can copy my project and put it on their own web server and see what it does without having actually accessing my info and login in into phpmyadmin.
Is This A Good Question/Topic? 0
  • +

Replies To: php file and github

#2 ndc85430  Icon User is online

  • I think you'll find it's "Dr"
  • member icon

Reputation: 654
  • View blog
  • Posts: 2,712
  • Joined: 13-June 14

Re: php file and github

Posted 30 December 2017 - 05:33 AM

One thing you could do is store the data in environment variables and read the values from there in your application.
Was This Post Helpful? 0
  • +
  • -

#3 [email protected]  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 57
  • Joined: 24-February 15

Re: php file and github

Posted 30 December 2017 - 05:38 AM

Thats what I mean the file needs to be in the same map to read it out. But if people download that map they will access it.

This post has been edited by Dormilich: 02 January 2018 - 02:08 AM

Was This Post Helpful? 0
  • +
  • -

#4 ndc85430  Icon User is online

  • I think you'll find it's "Dr"
  • member icon

Reputation: 654
  • View blog
  • Posts: 2,712
  • Joined: 13-June 14

Re: php file and github

Posted 30 December 2017 - 05:44 AM

I don't understand what you mean. Environment variables are set on the system and are accessible to applications.

Also, there's no need to quote the previous post. Just use the "Reply" button.

This post has been edited by ndc85430: 30 December 2017 - 05:45 AM

Was This Post Helpful? 0
  • +
  • -

#5 [email protected]  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 57
  • Joined: 24-February 15

Re: php file and github

Posted 30 December 2017 - 05:58 AM

You can put your databae info in your main php or another and access it from your main. If I put that on githib people will see this. My pass and username. How can I hide it from people.
Was This Post Helpful? 0
  • +
  • -

#6 ndc85430  Icon User is online

  • I think you'll find it's "Dr"
  • member icon

Reputation: 654
  • View blog
  • Posts: 2,712
  • Joined: 13-June 14

Re: php file and github

Posted 30 December 2017 - 06:00 AM

I already answered that: put the data in environment variables and read those in your code. If someone else clones your repo, they'll set the environment variables for the credentials of their database.
Was This Post Helpful? 0
  • +
  • -

#7 [email protected]  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 57
  • Joined: 24-February 15

Re: php file and github

Posted 30 December 2017 - 06:10 AM

I'm sorry but I really don't know what you mean by that. Can you give an example.
Was This Post Helpful? 0
  • +
  • -

#8 ndc85430  Icon User is online

  • I think you'll find it's "Dr"
  • member icon

Reputation: 654
  • View blog
  • Posts: 2,712
  • Joined: 13-June 14

Re: php file and github

Posted 30 December 2017 - 06:13 AM

Perhaps you should read these:

https://en.wikipedia...onment_variable
http://php.net/manua...tion.getenv.php
Was This Post Helpful? 0
  • +
  • -

#9 ndc85430  Icon User is online

  • I think you'll find it's "Dr"
  • member icon

Reputation: 654
  • View blog
  • Posts: 2,712
  • Joined: 13-June 14

Re: php file and github

Posted 30 December 2017 - 06:23 AM

I'm not a PHP developer, but here's an example in another language (Kotlin):

val dao = Dao(System.getenv("JDBC_DATABASE_URL"))


JDBC_DATABASE_URL is the name of an environment variable that stores, well, the URL to the database for my application. On Heroku, where the application runs, it's set to the URL of the real DB. When I run the application locally, I set it to the URL of the DB that's running on my machine. I read the value from the system using the System.getenv method and pass it to the thing that needs it.

The language may be different, but the idea is the same.
Was This Post Helpful? 0
  • +
  • -

#10 astonecipher  Icon User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2363
  • View blog
  • Posts: 9,485
  • Joined: 03-December 12

Re: php file and github

Posted 30 December 2017 - 09:01 AM

Add the config file to your .gitignore file
Was This Post Helpful? 0
  • +
  • -

#11 [email protected]  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 57
  • Joined: 24-February 15

Re: php file and github

Posted 30 December 2017 - 10:10 AM

So if I'm right I can put my config file in giftignore and make it global. And then access it with the variable environment thing. Still new to the variable environment and Github.
Was This Post Helpful? 0
  • +
  • -

#12 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4140
  • View blog
  • Posts: 13,091
  • Joined: 08-June 10

Re: php file and github

Posted 02 January 2018 - 02:14 AM

View Post[email protected], on 30 December 2017 - 06:10 PM, said:

So if I'm right I can put my config file in giftignore and make it global.

That has nothing to do with each other.

View Post[email protected], on 30 December 2017 - 06:10 PM, said:

Still new to the variable environment and Github.

Still has nothing to do with each other. maybe except that environment data are inaccessible to git.

a gitignore file simply tells git which files not to put under version control.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1