我试图在ubuntu中安装yii2。
yii2 migrate命令不起作用
yii migrate
I am getting Below error
php yii /var/www/event-tracking/migrate
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/ming.ini on line 1 in Unknown on line 0
Could not open input file: yii
安装应用程序后,必须执行以下步骤来初始化已安装的应用程序。这些你只需要做一次就可以了。
执行init
命令并选择dev作为环境。
php /path/to/yii-application/init
创建一个新的数据库,并相应地调整common/config/main-local.php
中的components.db配置。
使用控制台命令应用迁移:
yii migrate
或对于windows:
php yii migrate
这个命令应该在数据库中创建User,and Migration表
ref [Yii2 Documentation]
如果yii migrate
不工作,您也可以尝试php yii migrate
,因为yii命令只是需要运行的PHP文件。
如果您从git仓库克隆项目,可能会发生这种情况。"yii"被添加到。gitignore中。按照yii2安装-迁移命令中描述的说明操作如果你因为某些原因懒得或害怕这样做,只需复制"yii"文件和/config/*-local.php文件到你的项目目录。
在windows上使用以下命令
c:'php /path of your yii application/init
:
c:'php (path of your yii file which is in your application with file name) migrate
e.x:c:' xampp'htdocs'advanced'php migrate
advanced是应用程序的名称
可以使用PHP yii2 migrate
就发生在我身上,CLI php使用单独的。ini,我的错误被抑制,配置文件有一个错别字,我只能做
php -d display_errors=on yii
等瞧
错误我:-
user@mohit-pc:/var/www/html/yii2-app$ yii migrate——migrationPath=@mdm/admin/migrations
Command 'yii' not found, did you mean:
command 'ii' from deb ii
command 'yri' from deb yard
Try: sudo apt install <deb name>
解决方案进入项目的根目录,运行php yii migrate
user@mohit-pc:/var/www/html/yii2-app$ php yii migrate --migrationPath=@mdm/admin/migrations
Yii Migration Tool (based on Yii v2.0.43)
Creating migration history table "migration"...Done.
Total 2 new migrations to be applied:
m140602_111327_create_menu_table
m160312_050000_create_user
Apply the above migrations? (yes|no) [no]:yes
*** applying m140602_111327_create_menu_table
> create table {{%menu}} ... done (time: 0.041s)
*** applied m140602_111327_create_menu_table (time: 0.053s)
*** applying m160312_050000_create_user
> create table {{%user}} ... done (time: 0.034s)
*** applied m160312_050000_create_user (time: 0.050s)
2 migrations were applied.
Migrated up successfully.