LoginSignup
1
1

More than 5 years have passed since last update.

Bluemix で PHP のアプリを作成する

Last updated at Posted at 2017-07-14

IBM Bluemix で PHP のアプリを作成します。
まず、
CloudFoundry アプリの PHP で ひながたを作成します。

bluemix_hello_jul15.png

それを、次のような表示を出すように改造します。

bluemix_php_jul15.png

改造するのは、
index.php
付け加えるのは、
jquery-3.2.1.min.js
example_php.js
prog/example_php.php
です。

index.php
<!DOCTYPE html>
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="jquery-3.2.1.min.js"></script>
<script src="example_php.js"></script>
<link rel="stylesheet" href="style.css" />
<title>PHP Test (Jul/15/2017)</title>
</head>
<body>
<h1>こんにちは</h1>
<blockquote>
今日は晴れています<p />
</blockquote>
<hr />
<div class="contents">contents</div>
<hr />
<div id="outarea_aa">outarea_aa</div>
<div id="outarea_bb">outarea_bb</div>
<div id="outarea_cc">outarea_cc</div>
<div id="outarea_dd">outarea_dd</div>
<div id="outarea_ee">outarea_ee</div>
<div id="outarea_ff">outarea_ff</div>
<div id="outarea_gg">outarea_gg</div>
<div id="outarea_hh">outarea_hh</div>
<hr />
Jul/15/2017 AM 08:20<p />
</body>
</html>
example_php.js
// -----------------------------------------------------------------------
//  example_php.js
//
//                  Jul/15/2017
//
// -----------------------------------------------------------------------
jQuery (function ()
{
    jQuery("#outarea_aa").text ("*** js/example_php.js *** 開始 ***")

    var data_text = ""

    var url_in = "prog/example_php.php"

    jQuery.get (url_in,function (data_rec)
        {
        jQuery(".contents").html (data_rec)
        })

    var ua = window.navigator.userAgent
    var ver = window.navigator.appVersion

    jQuery("#outarea_bb").html ('ua : ' + ua + '<br />')
    jQuery("#outarea_cc").html ('ver : ' + ver + '<br />')

    jQuery("#outarea_hh").text ("*** js/example_php.js *** 終了 ***")

})

// -----------------------------------------------------------------------
prog/example_php.php
<?php
echo "*** generated by prog/example_php.php ***<br />";
date_default_timezone_set('Asia/Tokyo');
echo "<blockquote>";
echo "*** PHP runs on the server.***<p />";
echo date("Y/m/d  G:i") . "<br />";
echo $_SERVER['SERVER_SOFTWARE'] . "<br />";
echo $_SERVER['SERVER_NAME'] . "<br />";
echo $_SERVER['HTTP_USER_AGENT'] . "<br />";
echo $_SERVER['REMOTE_ADDR'] . "<br />";
echo gethostbyaddr ($_SERVER['REMOTE_ADDR']) . "<br />";
echo "</blockquote>";
echo "*** prog/example_php.php *** end ***<br />";
?>

変更が終わったら、ローカルで確認します。

php -S localhost:8000

うまく動いたら、アップロードします。
login の引数は、環境に合わせて変更して下さい。

bx api https://api.ng.bluemix.net
bx login -u aaa@bbb.net -p passaaa -o "aaa" -s my_area
bx app push
1
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
1
1