在得到 Herokai David Zuelke 的帮助后,我决定编写一个关于“在 Cloud9 中创建 Yii2 应用程序 → 推送到 Github → 部署到 Heroku”的方法。请参见下文(如果更容易阅读,请在顶部查看 Google 文档链接):
https://docs.google.com/document/d/15teHaGWUWSNW_VwdV3-7bVpQHNRv2G0Z8GPFbIB-ogs/edit
1) 创建 Yii2 “基础”应用:
290795 $ composer create-project --prefer-dist yiisoft/yii2-app-basic basic
2) 进入“基本”目录
290795 $ cd basic/
3) 为“基本”目录初始化本地仓库
basic $ git init
4) 添加并提交 Yii 项目
basic $ git add .
basic $ git commit -m "basic Yii project"
5) 在“web”目录中添加指向 index.php(入口脚本)的 procfile
basic $ echo "web: vendor/bin/heroku-php-apache2 web/" > Procfile
basic $ git add Procfile
basic $ git commit -m "Procfile for Heroku"
6) 注释掉调试内容(我手动而不是从命令行执行此操作)
basic $ vim web/index.php # remove dev/debug env stuff (not my way)
basic $ git add web/index.php
basic $ git commit -m "remove dev/debug env"
7) 这会将依赖关系从 v1.0.3 更新到 v1.1(绝对必要)
basic $ composer require fxp/composer-asset-plugin
basic $ git add composer.json composer.lock
basic $ git commit -m "use fxp/composer-asset-plugin in project"
8) 创建 Heroku 应用并推送到它。 (我改为创建并推送到 Github 存储库)
basic $ heroku create
basic $ git push heroku master (again I push to Github Repo synced with Heroku)
9) 为 Yii 应用程序添加日志记录到 Heroku(没有开箱即用的 Yii 日志记录)
basic $ echo "web: vendor/bin/heroku-php-apache2 -l runtime/logs/app.log web/" > Procfile
basic $ git add Procfile
basic $ git commit -m "tail runtime/logs/app.log"
basic $ git push heroku master (again I push to Github Repo synced with Heroku)
10) 这允许“联系”页面工作(不知道为什么)
basic $ composer require ext-gd:* --ignore-platform-reqs
basic $ git add composer.json composer.lock
basic $ git commit -m "require GD for contact CAPTCHA"
basic $ git push heroku master (again I push to Github Repo synced with Heroku)