Skip to content

Commit 0979766

Browse files
committed
fix: update README.md
1 parent 10a0fbb commit 0979766

File tree

5 files changed

+73
-4
lines changed

5 files changed

+73
-4
lines changed

README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,53 @@
1-
# TODO
1+
# Yii2 Bridge Migrate Command
2+
3+
If you cannot start `yii2-bridge/core` migrations using a terminal (especially if your project is on a shared hosting), install this package and start migrating via `php`.
4+
5+
## Installation
6+
7+
### Composer
8+
9+
The preferred way to install this extension is through [Composer](http://getcomposer.org/).
10+
11+
Either run:
12+
```
13+
composer require yii2-bridge/migrate-command:^0.1
14+
```
15+
16+
or add `"yii2-bridge/migrate-command": "^0.1"` to the require section of your `composer.json`
17+
18+
### Using
19+
20+
Add a module `Bridge\Migrate\Modules\Module` in the configuration file of the console application to the modules section of the admin module:
21+
22+
```php
23+
'console' => [
24+
...
25+
'modules' => [
26+
'admin' => [
27+
'class' => \Bridge\Core\BridgeModule::class,
28+
'modules' => [
29+
'migrate' => [
30+
'class' => 'Bridge\Migrate\Modules\Module',
31+
],
32+
],
33+
...
34+
]
35+
],
36+
...
37+
]
38+
```
39+
40+
To start the migration, just run the command:
41+
```
42+
php yii admin/migrate
43+
```
44+
45+
---
46+
47+
If you want to run migrations on a shared hosting, you can run as php script through cron.
48+
For example for shared hosting PS.kz:
49+
![PS.kz](./images/ps.png)
50+
51+
## Author
52+
53+
[Altynbek Kazezov](https://github.com/altynbek07/), e-mail: [altynbek.kazezov.97@gmail.com](mailto:altynbek.kazezov.97@gmail.com)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"authors": [
1414
{
1515
"name": "Altynbek Kazezov",
16-
"email": "altinbek__97@mail.ru",
16+
"email": "altynbek.kazezov.97@gmail.com",
1717
"role": "Developer"
1818
}
1919
],

images/ps.png

190 KB
Loading

src/Module.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
namespace Bridge\Migrate\Modules;
44

5+
use yii\base\Module as BaseModule;
6+
57
/**
68
* Class Module
79
* @package Bridge\Migrate\Modules
810
*/
9-
class Module extends \yii\base\Module
11+
class Module extends BaseModule
1012
{
13+
/**
14+
* @var string $controllerNamespace
15+
*/
1116
public $controllerNamespace = 'Bridge\Migrate\Controllers';
1217
}

src/controllers/DefaultController.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,25 @@
33
namespace Bridge\Migrate\Controllers;
44

55
use yii\console\Controller;
6+
use yii\helpers\Console;
67
use Yii;
78

9+
/**
10+
* DefaultController
11+
* @package Bridge\Migrate\Controllers
12+
*/
813
class DefaultController extends Controller
914
{
15+
/**
16+
* This action runs the migration commands for the `yii2-bridge/core` package.
17+
*
18+
* @link https://github.com/yii2-bridge/core
19+
* @return void
20+
*/
1021
public function actionIndex()
1122
{
1223
$result = shell_exec(Yii::getAlias('@app') . '/vendor/bin/bridge-install');
13-
echo $result;
24+
25+
$this->stdout($result . "\n", Console::FG_GREEN);
1426
}
1527
}

0 commit comments

Comments
 (0)