alwex/phpdeploy
Composer 安装命令:
composer require alwex/phpdeploy
包简介
full php deployment tool to automate code deployment on multiple hosts/env
README 文档
README
php-deploy is a full php deployment tool designed to allow very common OR very specific tasks. It's main philosophy is to chain commands as described in a simple configuration file, commands are easily extensible and highly customizable.
Installation using composer
If you use composer you can easily use it on your project. The main binary file will be available on your binary path
bin/pdeploy and ready to use.
composer require alwex/phpdeploy
Initiating the project
To use php-deploy you have to initialize your project. Some directory and basic configuration files will be created under the
.php-deploy directory located in the root of your project.
bin/pdeploy config:init myproject
- .php-deploy/config.ini -> the main configuration file which describe the global project configuration
- .php-deploy/environments -> environment configuration files goes here
- .php-deploy/Command -> you put your custom commands here
You may want to modify the config.ini file
Adding some environments
In order to add environments simply type
bin/pdeploy config:addenv production
Environment file example:
# user used for all remote commands login=mySshLogin # directory where the project is located # relatively to the path where you execute # bin/pdeploy fromDirectory = ./ # remote or local path where to deploy # the application toDirectory = /var/www # list of hosts where to deploy the app hosts[] = 'localhost' hosts[] = 'web1' hosts[] = 'web2' # ... # name of the symlink allowing # multiple apps in the same path symlink = current-php-deploy [deploy] # PRE TASK # executed before task # usually vcs export and build # of the package to deploy preTask[] = Deploy\Command\GitExport preTask[] = Deploy\Command\ComposerInstall preTask[] = Deploy\Command\TarGz # deployment stage executed against # each hosts onTask[] = Deploy\Command\Scp onTask[] = Deploy\Command\UnTarGz # post deployment stage executed # on each hosts, usually cache clear, # apache reload and symlink generation # after this stage, deployment is done! postTask[] = Deploy\Command\Symlink # after tasks executed one time only afterTask[] = ExampleCommand # custom comand [mytask] # PRE TASK preTask[] = Deploy\Command\Symlink # ON TASK onTask[] = Deploy\Command\Symlink # POST TASK postTask[] = Deploy\Command\Symlink # AFTER TASK afterTask[] = Deploy\Command\Symlink # ... and so on as many tasks as necessary
Executing a task
Once you have defined the tasks on the environment ini files, you can simply run them with
bin/pdeploy task:run --release=0.0.1 --env=production mytask
Creating custom commands
To add custom commands, simply add it as php classes on the folder .php-deploy/Command, you can duplicate the ExampleCommand.php to start.
Just add this custom command to a task like for example
afterTask[] = ExampleCommand
ExampleCommand content:
class ExampleCommand extends \Deploy\Command\AbstractCommand { /** * optionally you may check if all the * requirement are met before running * the command * * @throw \RuntimeException */ public function beforeRun() { if (file_exists("/tmp/hello.txt")) { throw new \RuntimeException("hello file already exists"); } } /** * execute command and php tasks * return the execution status as an integer * * @return void */ public function run() { $command = "echo hello > /tmp/hello.txt"; $this->shellExec($command); } /** * optionally you may check if the command has been * correctly done * * @throw \RuntimeException */ public function afterRun() { $expectedValue = 'hello'; $fileContent = file_get_contents("/tmp/hello.txt"); if ($fileContent != $expectedValue) { throw new \RuntimeException("hello file does not contain expected value '$expectedValue', found '$fileContent'"); } } }
alwex/phpdeploy 适用场景与选型建议
alwex/phpdeploy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 231 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 02 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 alwex/phpdeploy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alwex/phpdeploy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 231
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-02-12