LoginSignup
3
1

More than 3 years have passed since last update.

APIのKeyをGithubに上げたくないのでしたこと(PHP)

Posted at

Google Map APIを利用する際に、自分のAPI keyをGithubに上げたくないので、方法を探していたが、結局以下の方法で動いているのでよしとした。

APIへのアクセス部分は
<script src="https://maps.googleapis.com/maps/api/js?key=<?php include("keys/googlemap.php"); ?>&callback=initMap"></script>

上記アクセス部分が書かれているファイルと同じ階層にディレクトリ「keys」をつくり、その中にファイル名「googlemap.php」でファイルを作成後、そのファイルの中にテキストで自分のAPI keyの値を書くだけ。

そのあと、.gitignoreファイルの中に「keys/」を追加。

以上

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1