https://techcrunch.com/2010/12/08/breaking-salesforce-buys-heroku-for-212-million-in-cash/
https://en.wikipedia.org/wiki/Heroku
http://myapp630306.herokuapp.com (wordpress / postgresqlworking.php)
http://ancient-hollows-032330.herokuapp.com/ (no such app)
http://safe-hamlet-06492.herokuapp.com/p10.php (print 1 to 10)
http://thaiall63.herokuapp.com (phpinfo)
Platform as a service (PaaS)
https://thaiall63.herokuapp.com/
https://safe-hamlet-06492.herokuapp.com/
Download heroku-x64.exe แล้วติดตั้ง
cmd
heroku login
เปิด browser แล้ว login ก็จะได้สถานะว่า logged in as [your email]
php -v
PHP 7.0.5 (cli) (built: Apr 26 2016 04:39:48) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
Now check that you have composer installed. If not, install it and test again:
composer -V
Composer version 1.4.1 2017-03-10 09:29:45
Now check that you have git installed. If not, install it and test again.
git --version
git version 2.12.2
https://www.apachefriends.org/download.html
https://getcomposer.org/Composer-Setup.exe
ค้น Edit the system environment variables
เพิ่ม c:\xampp7\php และ c:\composer
เข้า DOS พิมพ์ set ดูได้
composer -v
php -v
git --version
d:
mkdir heroku
cd heroku
git clone https://github.com/thaiall/mytest.git
cd mytest
heroku create
git push heroku master
heroku ps:scale web=1
heroku open
https://safe-hamlet-06492.herokuapp.com/
View logs
heroku logs --tail
ctrl-c
heroku ps
notepad composer.json
{
"require" : {
"silex/silex": "^2.0.4",
"monolog/monolog": "^1.22",
"twig/twig": "^2.0",
"symfony/twig-bridge": "^3"
},
"require-dev": {
"heroku/heroku-buildpack-php": "*"
}
}
composer update
git add .
git config --global user.email "thaiall@hotmail.com"
git config --global user.name "burin"
git commit -m "Demo"
git push heroku master
heroku open index.files
heroku run "php -a"
echo PHP_VERSION;
quit
heroku run bash
ls
exit
heroku run bash
---
http://www.thaiall.com/git/
d:
cd heroku
cd thaiall63
git clone https://git.heroku.com/thaiall63.git
พบ thaiall63/thaiall63 ตอนนี้ว่างเปล่า
สร้าง index.php มี phpinfo()
cd thaiall63 ในห้องที่มี .git
git add .
git config --global user.email "thaiall@hotmail.com"
git config --global user.name "burin"
git commit -m "hello"
git push origin master
https://thaiall63.herokuapp.com/
--------------------
Heroku git URL https://git.heroku.com/safe-hamlet-06492.git
https://safe-hamlet-06492.herokuapp.com/
D:\heroku>mkdir hamlet
D:\heroku>cd hamlet
D:\heroku\hamlet>git clone https://git.heroku.com/safe-hamlet-06492.git
D:\heroku\hamlet>cd safe-hamlet-06492
D:\heroku\hamlet\safe-hamlet-06492>echo ^<?php for($i=1;$i^<=10;$i++){ echo $i; } ?^> > p10.php
D:\heroku\hamlet\safe-hamlet-06492>type p10.php
D:\heroku\hamlet\safe-hamlet-06492>git add p10.php
D:\heroku\hamlet\safe-hamlet-06492>git config --global user.email "thaiall@hotmail.com"
D:\heroku\hamlet\safe-hamlet-06492>git config --global user.name "burin"
D:\heroku\hamlet\safe-hamlet-06492>git commit -m "hello"
D:\heroku\hamlet\safe-hamlet-06492>git push origin master
https://safe-hamlet-06492.herokuapp.com/p10.php
------
ดูใน view logs พบ error
[04-Mar-2020 04:50:20 UTC] PHP Parse error: syntax error, unexpected '$i' (T_VARIABLE) in /app/p10.php on line 1
https://dashboard.heroku.com/apps/safe-hamlet-06492/logs
D:\heroku\hamlet\safe-hamlet-06492>echo ^<?php for($i=1;$i^<=10;$i++){ echo $i; } ?^> > p10.php
D:\heroku\hamlet\safe-hamlet-06492>type p10.php
D:\heroku\hamlet\safe-hamlet-06492>git add p10.php
D:\heroku\hamlet\safe-hamlet-06492>git config --global user.email "thaiall@hotmail.com"
D:\heroku\hamlet\safe-hamlet-06492>git config --global user.name "burin"
D:\heroku\hamlet\safe-hamlet-06492>git commit -m "hello"
D:\heroku\hamlet\safe-hamlet-06492>git push origin master
D:\heroku\hamlet\safe-hamlet-06492>explorer https://safe-hamlet-06492.herokuapp.com/p10.php
บริการ Heroku Postgres
Create one
Install Heroku Postgres
$heroku addons:create heroku-postgresql:hobby-dev
เลือก ancient-hollows-03230 ที่ยังไม่ระบุ framework
คลิ๊ก Provision add-on
ใต้ Resources ของ ancient-hollows-03230 จะพบ Heroku Postgres
ดูสถานของฐานข้อมูล https://data.heroku.com/datastores/d3d0cf8f-b5de-4371-93a3-9301c31841e5
https://git.heroku.com/ancient-hollows-03230.git
C:\users\lab>d:
D:\>cd heroku
D:\heroku>mkdir ancient
D:\heroku>cd ancient
D:\heroku\ancient>git clone https://git.heroku.com/ancient-hollows-03230.git
Cloning into 'ancient-hollows-03230'...
warning: You appear to have cloned an empty repository.
D:\heroku\ancient>cd ancient-hollows-03230
D:\heroku\ancient\ancient-hollows-03230>notepad composer.json
{
"require-dev": {
"heroku/heroku-buildpack-php": "*"
}
}
composer update
D:\heroku\ancient\ancient-hollows-03230>echo ^<?php for($i=1;$i^<=10;$i++){ echo $i; } ?^> > p10.php
D:\heroku\ancient\ancient-hollows-03230>git add p10.php
D:\heroku\ancient\ancient-hollows-03230>git commit -m "hello"
[master (root-commit) e548a61] hello
1 file changed, 1 insertion(+)
create mode 100644 p10.php
D:\heroku\ancient\ancient-hollows-03230>git push origin master
'push' is not recognized as an internal or external command,
operable program or batch file.
D:\heroku\ancient\ancient-hollows-03230>git push origin master
! No default language could be detected for this app.
---
D:\heroku\ancient\ancient-hollows-03230>heroku buildpacks
D:\heroku\ancient\ancient-hollows-03230>heroku buildpacks:set heroku/php
D:\heroku\ancient\ancient-hollows-03230>heroku create ancient-hollows-03230 --buildpack heroku/php
Buildpack set. Next release on ancient-hollows-03230 will use heroku/php.
Run git push heroku master to create a new release using this buildpack.
---
heroku create myapp630306 --buildpack heroku/php
git clone https://git.heroku.com/myapp630306.git
cd myapp630306
echo ^<?php for($i=1;$i^<=10;$i++){ echo $i; } ?^> > p10.php // index.php
git add p10.php
git config --global user.email "thaiall@hotmail.com"
git config --global user.name "burin"
git commit -m "Demo"
git push origin master
---
https://myapp630306.herokuapp.com/
https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-php
<?php
$db = parse_url(getenv("DATABASE_URL"));
echo $db["host"]. __LINE__;
$pdo = new PDO("pgsql:" . sprintf(
"host=%s;port=%s;user=%s;password=%s;dbname=%s",
$db["host"],
$db["port"],
$db["user"],
$db["pass"],
ltrim($db["path"], "/")
));
?>
---
Cloud Application Platform
heroku git:clone -a APP-NAME
heroku slugs:download -a APP_NAME
---
heroku login
launch browser to login http://www.heroku.com
https://devcenter.heroku.com/articles/heroku-cli
Download heroku-x64.exe แล้วติดตั้ง
git clone https://git.heroku.com/myapp630306.git
cd myapp630306
notepad index.php
git add index.php
git config --global user.email "thaiall@hotmail.com"
git config --global user.name "burin"
git commit -m "Demo"
git push origin master