jacmoe / yii2-app-advanced-deployer
支持Deployer.php的Yii 2高级项目模板
Requires
- php: >=5.4.0
- yiisoft/yii2: >=2.0.6
- yiisoft/yii2-bootstrap: *
- yiisoft/yii2-swiftmailer: *
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-26 00:19:42 UTC
README
支持Deployer.php的Yii 2高级项目模板是一个用于开发多级复杂Web应用的骨架Yii 2应用程序。
该模板包括三个级别:前端、后端和命令行,每个级别都是一个单独的Yii应用程序。
该模板旨在在团队开发环境中使用。它支持在不同的环境中部署应用程序。
文档位于docs/guide/README.md。
这和标准的先进应用有什么不同?
- 此项目可以通过Deployer部署
- 在
frontend/web
和backend/web
文件夹中添加了.htaccess
文件,并且已开启FollowSymlinks。 - 已删除初始化脚本,因为Deployer根据
deployer/stage/servers.yml
中的值配置项目。
它是如何工作的?
请参阅我的博客文章使用Deployer部署Yii
相关
目录结构
common
config/ contains shared configurations
mail/ contains view files for e-mails
models/ contains model classes used in both backend and frontend
console
config/ contains console configurations
controllers/ contains console controllers (commands)
migrations/ contains database migrations
models/ contains console-specific model classes
runtime/ contains files generated during runtime
deployer
recipe/ contains deployer recipes
stage/ contains deployer server configurations
environments/ contains environment based templates
configured by Deployer according to
the values in `deployer/stage/servers.yml`
backend
assets/ contains application assets such as JavaScript and CSS
config/ contains backend configurations
controllers/ contains Web controller classes
models/ contains backend-specific model classes
runtime/ contains files generated during runtime
views/ contains view files for the Web application
web/ contains the entry script and Web resources
frontend
assets/ contains application assets such as JavaScript and CSS
config/ contains frontend configurations
controllers/ contains Web controller classes
models/ contains frontend-specific model classes
runtime/ contains files generated during runtime
views/ contains view files for the Web application
web/ contains the entry script and Web resources
widgets/ contains frontend widgets
vendor/ contains dependent 3rd-party packages
tests contains various tests for the advanced application
codeception/ contains tests developed with Codeception PHP Testing Framework
需求
本项目模板对Web服务器的最低要求是支持PHP 5.4.0。
Deployer
mv deployer.phar /usr/local/bin/dep
chmod +x /usr/local/bin/dep
有关更多信息,请参阅Deployer - 安装
安装
通过Composer安装
如果您没有Composer,您可以通过遵循getcomposer.org上的说明来安装它。
然后,您可以使用以下命令安装此项目模板
php composer.phar global require "fxp/composer-asset-plugin:~1.1.1"
php composer.phar create-project --prefer-dist --stability=dev jacmoe/yii2-app-advanced-deployer advanced
部署
servers.yml
首先,在deployer/stage
目录中创建一个名为servers.yml
的文件。
您可以将servers-sample.yml
的内容复制过来以开始。
在服务器上创建数据库
在部署之前,请确保您已经在您想要部署到的服务器上创建了一个数据库。
deploy命令
当您创建了服务器配置文件后,您只需运行此命令
dep deploy production
或
dep deploy local
注意,本地阶段的本地服务器配置需要有一个名为local
的键,这将使Deployer创建一个不使用ssh的本地服务器。
如果活动阶段的服务器未设置本地,您需要在本地机器上有一个ssh服务器(sudo apt-get install openssh-server
)。
不部署配置
在开发时,通常会在本地提供项目服务,因此此项目模板附带了一个配置文件的功能,设置可写目录并安装供应商。
只需运行
dep inplace local
此命令假设您已在servers.yml
配置文件中将部署目录设置为指向您的当前源目录(您所在的目录)。