PHPackages                             lesha724/selfupdate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [DevOps &amp; Deployment](/categories/devops)
4. /
5. lesha724/selfupdate

ActiveYii2-extension[DevOps &amp; Deployment](/categories/devops)

lesha724/selfupdate
===================

Basic extension for the Yii2 project self-update from VCS

v0.0.2(3y ago)024BSD-3-ClausePHPPHP &gt;=5.6

Since Aug 24Pushed 3y agoCompare

[ Source](https://github.com/lesha724/selfupdate)[ Packagist](https://packagist.org/packages/lesha724/selfupdate)[ GitHub Sponsors](https://github.com/klimov-paul)[ Patreon](https://www.patreon.com/klimov_paul)[ RSS](/packages/lesha724-selfupdate/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

 [ ![](https://avatars2.githubusercontent.com/u/12951949) ](https://github.com/yii2tech)

Project Self Update Extension for Yii 2
=======================================

[](#project-self-update-extension-for-yii-2)

This extension allows automatic project updating in case its source code is maintained via version control system, such as [GIT](https://git-scm.com/) or [Mercurial](https://mercurial.selenic.com/). Such update includes following steps:

- check if there are any changes at VSC remote repository
- link web server web directories to the stubs, while project update is running
- apply remote VCS changes
- update 'vendor' directory via Composer
- clear application cache and temporary directories
- perform additional actions, like applying database migrations
- link web server web directories to the project web directories, once update is complete
- notify developer(s) about update result via email

> Note: this solution is very basic and may not suite for the complex project update workflow. You may consider usage of more sophisticated tools like [Phing](https://www.phing.info/). However, this extension may be used as a part of such solution.

For license information check the [LICENSE](LICENSE.md)-file.

[![Latest Stable Version](https://camo.githubusercontent.com/6c8a7cef2bc1b08a7a36ce63458fdf2fec96f3358afc4cef9145bdbfc1da7a3e/68747470733a2f2f706f7365722e707567782e6f72672f79696932746563682f73656c667570646174652f762f737461626c652e706e67)](https://packagist.org/packages/yii2tech/selfupdate)[![Total Downloads](https://camo.githubusercontent.com/23b8bcc998d5de2d3b7c9c32338e66ff795dbdc62e0ad51d14b8539ccce24318/68747470733a2f2f706f7365722e707567782e6f72672f79696932746563682f73656c667570646174652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/yii2tech/selfupdate)[![Build Status](https://camo.githubusercontent.com/87a403375b04b70aef514067d10d819369df1b5a0cde0b256bb17a65c059df1e/68747470733a2f2f7472617669732d63692e6f72672f79696932746563682f73656c667570646174652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/yii2tech/selfupdate)

Requirements
------------

[](#requirements)

This extension requires Linux OS.

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist yii2tech/selfupdate

```

or add

```
"yii2tech/selfupdate": "*"
```

to the require section of your composer.json.

Usage
-----

[](#usage)

This extension provides special console controller \[\[yii2tech\\selfupdate\\SelfUpdateController\]\], which allows automatic updating of the project, if its source code is maintained via version control system. In order to enable this controller in your project, you should add it to your console application `controllerMap` at configuration file:

```
return [
    'controllerMap' => [
        'self-update' => 'yii2tech\selfupdate\SelfUpdateController'
    ],
    // ...
];
```

Now you should able to use 'self-update' command via console:

```
yii self-update

```

Project preparation
--------------------

[](#project-preparation-)

In order to use 'self-update' command, you should perform several preparations in your project, allowing certain shell commands to be executed in non-interactive (without user prompt) mode.

First of all, you should clone (checkout) your project from version control system and switch project working copy to the branch, which should be used at this particular server. Using GIT this actions can be performed via following commands:

```
cd /path/to/my/project
git clone git@my-git-server.com/myproject.git
git checkout production

```

> Attention: you need to configure your VCS (or at least your project working copy) in the way interacting with remote repository does NOT require user prompt, like input of username or password! This can be achieved using authentication keys or 'remember password' feature.

Then you should make project operational performing all necessary actions for its initial deployment, like running 'composer install', creating necessary directories and so on.

Using self-update command
--------------------------

[](#using-self-update-command-)

Once project is setup you need to create a configuration for its updating. This can be done using 'self-update/config' command:

```
yii self-update/config @app/config/self-update.php

```

This will generate configuration file, which should be manually adjusted depending on the particular project structure and server environment. For the common project such configuration file may look like following:

```
