dnunez24 / platformsh-deploy-php
库,用于为托管在 Platform.sh 上的 PHP 应用程序创建构建和部署过程
dev-master
2017-03-09 06:08 UTC
Requires
- php: >=5.6
- symfony/console: ~3.2.0
Requires (Dev)
This package is not auto-updated.
Last update: 2024-09-28 20:30:37 UTC
README
这是一个基础库,用于为托管在 Platform.sh 上的 PHP 应用程序创建构建和部署过程。
入门
通过扩展此库中的抽象类来实现你的具体构建策略
<?php namespace MyVendor\MyApp\Strategy; use Dnunez24\Platformsh\Strategy\AbstractBuildStrategy; class BuildStrategy extends AbstractBuildStrategy { public function build() { // add your build steps here } }
你也可以直接实现策略接口
<?php namespace MyVendor\MyApp\Strategy; use Dnunez24\Platformsh\Strategy\BuildStrategyInterface; class BuildStrategy implements BuildStrategyInterface { public function build() { // add your build steps here } }
创建你的构建命令
<?php namespace MyVendor\MyApp\Command; use Dnunez24\Platformsh\Command\AbstractBuildCommand; class MyBuildCommand extends AbstractBuildCommand { protected function configure() { // Add Symfony Console configuration steps here // See: https://symfony.com.cn/doc/current/console.html#configuring-the-command } }
然后在你项目的某个位置(例如 bin/myapp)创建 Symfony Console 应用程序
#!/usr/bin/env php <?php use Symfony\Component\Console\Application; use MyVendor\MyApp\Strategy\BuildStrategy; use MyVendor\MyApp\Strategy\DeployStrategy; use MyVendor\MyApp\Command\BuildCommand; use MyVendor\MyApp\Command\DeployCommand; $buildStrategy = new BuildStrategy(); $buildCommand = new BuildCommand($buildStrategy); $deployStrategy = new DeployStrategy(); $deployCommand = new DeployCommand($deployStrategy) $application = new Application(); $application->add($buildCommand); $application->add($deployCommand); $application->run();
最后,运行你的脚本来构建和部署应用程序
composer exec bin/myapp build composer exec bin/myapp deploy