{"id":15169495,"url":"https://github.com/yii2tech/selfupdate","last_synced_at":"2025-10-01T02:31:15.678Z","repository":{"id":33939929,"uuid":"37664798","full_name":"yii2tech/selfupdate","owner":"yii2tech","description":"Basic script for project self update from VCS","archived":true,"fork":false,"pushed_at":"2019-07-03T10:22:28.000Z","size":45,"stargazers_count":92,"open_issues_count":0,"forks_count":14,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-04-26T22:00:58.654Z","etag":null,"topics":["selfupdate","support","yii","yii2","yii2-extension"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yii2tech.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["klimov-paul"],"patreon":"klimov_paul"}},"created_at":"2015-06-18T14:36:46.000Z","updated_at":"2023-11-07T12:39:56.000Z","dependencies_parsed_at":"2022-07-13T17:00:38.276Z","dependency_job_id":null,"html_url":"https://github.com/yii2tech/selfupdate","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yii2tech%2Fselfupdate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yii2tech%2Fselfupdate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yii2tech%2Fselfupdate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yii2tech%2Fselfupdate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yii2tech","download_url":"https://codeload.github.com/yii2tech/selfupdate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219875269,"owners_count":16554660,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["selfupdate","support","yii","yii2","yii2-extension"],"created_at":"2024-09-27T07:02:19.021Z","updated_at":"2025-10-01T02:31:15.252Z","avatar_url":"https://github.com/yii2tech.png","language":"PHP","funding_links":["https://github.com/sponsors/klimov-paul","https://patreon.com/klimov_paul"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/yii2tech\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://avatars2.githubusercontent.com/u/12951949\" height=\"100px\"\u003e\n    \u003c/a\u003e\n    \u003ch1 align=\"center\"\u003eProject Self Update Extension for Yii 2\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\nThis extension allows automatic project updating in case its source code is maintained via version control system, such\nas [GIT](https://git-scm.com/) or [Mercurial](https://mercurial.selenic.com/). Such update includes following steps:\n - check if there are any changes at VSC remote repository\n - link web server web directories to the stubs, while project update is running\n - apply remote VCS changes\n - update 'vendor' directory via Composer\n - clear application cache and temporary directories\n - perform additional actions, like applying database migrations\n - link web server web directories to the project web directories, once update is complete\n - notify developer(s) about update result via email\n\n\u003e Note: this solution is very basic and may not suite for the complex project update workflow. You may consider\n  usage of more sophisticated tools like [Phing](https://www.phing.info/). However, this extension may be used as a part\n  of such solution.\n\nFor license information check the [LICENSE](LICENSE.md)-file.\n\n[![Latest Stable Version](https://poser.pugx.org/yii2tech/selfupdate/v/stable.png)](https://packagist.org/packages/yii2tech/selfupdate)\n[![Total Downloads](https://poser.pugx.org/yii2tech/selfupdate/downloads.png)](https://packagist.org/packages/yii2tech/selfupdate)\n[![Build Status](https://travis-ci.org/yii2tech/selfupdate.svg?branch=master)](https://travis-ci.org/yii2tech/selfupdate)\n\n\nRequirements\n------------\n\nThis extension requires Linux OS.\n\n\nInstallation\n------------\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\nphp composer.phar require --prefer-dist yii2tech/selfupdate\n```\n\nor add\n\n```json\n\"yii2tech/selfupdate\": \"*\"\n```\n\nto the require section of your composer.json.\n\n\nUsage\n-----\n\nThis extension provides special console controller [[yii2tech\\selfupdate\\SelfUpdateController]], which allows automatic updating of\nthe project, if its source code is maintained via version control system.\nIn order to enable this controller in your project, you should add it to your console application `controllerMap` at\nconfiguration file:\n\n```php\nreturn [\n    'controllerMap' =\u003e [\n        'self-update' =\u003e 'yii2tech\\selfupdate\\SelfUpdateController'\n    ],\n    // ...\n];\n```\n\nNow you should able to use 'self-update' command via console:\n\n```\nyii self-update\n```\n\n\n## Project preparation \u003cspan id=\"project-preparation\"\u003e\u003c/span\u003e\n\nIn order to use 'self-update' command, you should perform several preparations in your project, allowing\ncertain shell commands to be executed in non-interactive (without user prompt) mode.\n\nFirst of all, you should clone (checkout) your project from version control system and switch project working copy\nto the branch, which should be used at this particular server. Using GIT this actions can be performed via following commands:\n\n```\ncd /path/to/my/project\ngit clone git@my-git-server.com/myproject.git\ngit checkout production\n```\n\n\u003e Attention: you need to configure your VCS (or at least your project working copy) in the way interacting with remote\n  repository does NOT require user prompt, like input of username or password! This can be achieved using authentication\n  keys or 'remember password' feature.\n\nThen you should make project operational performing all necessary actions for its initial deployment, like running\n'composer install', creating necessary directories and so on.\n\n\n## Using self-update command \u003cspan id=\"using-self-update-command\"\u003e\u003c/span\u003e\n\nOnce project is setup you need to create a configuration for its updating. This can be done using 'self-update/config'\ncommand:\n\n```\nyii self-update/config @app/config/self-update.php\n```\n\nThis will generate configuration file, which should be manually adjusted depending on the particular project structure\nand server environment. For the common project such configuration file may look like following:\n\n```php\n\u003c?php\n\nreturn [\n    // list of email addresses, which should be used to send execution reports\n    'emails' =\u003e [\n        'developer@domain.com',\n    ],\n    // Mailer component to be used\n    'mailer' =\u003e 'mailer',\n    // Mutex component to be used\n    'mutex' =\u003e 'mutex',\n    // path to project root directory (VCS root directory)\n    'projectRootPath' =\u003e '@app',\n    // web path stubs configuration\n    'webPaths' =\u003e [\n        [\n            'path' =\u003e '@app/web',\n            'link' =\u003e '@app/httpdocs',\n            'stub' =\u003e '@app/webstub',\n        ],\n    ],\n    // cache components to be flushed\n    'cache' =\u003e [\n        'cache'\n    ],\n    // temporary directories, which should be cleared after project update\n    'tmpDirectories' =\u003e [\n        '@app/web/assets',\n        '@runtime/URI',\n        '@runtime/HTML',\n        '@runtime/debug',\n    ],\n    // list of shell commands, which should be executed after project update\n    'afterUpdateCommands' =\u003e [\n        'php ' . escapeshellarg($_SERVER['SCRIPT_FILENAME']) . ' migrate/up --interactive=0',\n    ],\n];\n```\n\nPlease refer to [[\\yii2tech\\selfupdate\\SelfUpdateController]] for particular option information.\n\nOnce you have made all necessary adjustments at configuration file, you can run 'self-update/perform' command with it:\n\n```\nyii self-update @app/config/self-update.php\n```\n\nYou may setup default configuration file name inside the `controllerMap` specification via [[yii2tech\\selfupdate\\SelfUpdateController::$configFile]]:\n\n```php\nreturn [\n    'controllerMap' =\u003e [\n        'self-update' =\u003e [\n            'class' =\u003e 'yii2tech\\selfupdate\\SelfUpdateController',\n            'configFile' =\u003e '@app/config/self-update.php',\n        ]\n    ],\n    // ...\n];\n```\n\nThen invocation of the self-update command will be much more clear:\n\n```\nyii self-update\n```\n\n\u003e Note: it is not necessary to create a separated configuration file: you can configure all necessary fields of\n  [[yii2tech\\selfupdate\\SelfUpdateController]] inside `controllerMap` specification, but such approach is not recommended.\n\n\nSelf Update Workflow\n--------------------\n\nWhile running, [[yii2tech\\selfupdate\\SelfUpdateController]] performs following steps:\n\n - check if there are any changes at VSC remote repository\n - link web server web directories to the stubs, while project update is running\n - apply remote VCS changes\n - update 'vendor' directory via Composer\n - clear application cache and temporary directories\n - perform additional actions, like applying database migrations\n - link web server web directories to the project web directories, once update is complete\n - notify developer(s) about update result via email\n\nAt the first stage there is a check for any changes in the remote repository. If there is no changes in remote\nrepository for the current project VCS working copy branch, no further actions will be performed!\n\nIf remote changes detected, the symbolic links pointing to the project '@web' directory will be switched to another\ndirectory, which should contain a 'stub' - some static HTML page, which says something like 'Application is under the\nmaintenance, please check again later'. Although, usage of such stub it is up to you, it is recommended, because actual\nproject update may take significant time before being complete.\nProject web directory will be linked back instead of stub, only after all update actions are performed.\n\nDuring update itself VCS remote changes are applied, `vendor` directory is updated via Composer, specified temporary\ndirectories will be cleared and cache flushed.\n\n\u003e Note: in order for Composer be able to apply necessary changes, the 'composer.lock' file should be tracked by version\n  control system!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyii2tech%2Fselfupdate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyii2tech%2Fselfupdate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyii2tech%2Fselfupdate/lists"}