-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding use Yii;
in the beginning of migration kills console
#8206
Comments
what is the error you see? can you paste an example on how you added this? Do you have any php extensions installed like apc for example? |
This is the migration code: <?php
use Yii;
use yii\db\Schema;
use yii\db\Migration;
class m150427_130904_test extends Migration
{
public function up()
{
}
public function down()
{
}
} and this is the effect of running it (Polish Windows, but you get the picture, right?): And this is my extension=php_bz2.dll
extension=php_curl.dll
extension=php_mbstring.dll
extension=php_exif.dll
extension=php_fileinfo.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mssql.dll
;extension=php_mbstring.dll
;extension=php_exif.dll ; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client
;extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client
extension=php_openssl.dll
;extension=php_pdo_firebird.dll
extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
extension=php_pdo_sqlite.dll
;extension=php_pdo_sqlite_external.dll
;extension=php_pgsql.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=php_snmp.dll
extension=php_soap.dll
extension=php_sockets.dll
extension=php_sqlite3.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll No APC or other cache, no magic, no nothing. Just an old, bit modified XAMPP running on Windows 7. |
I'll try reproducing it. |
Go ahead. Just added my list of extensions. Can provide you (zipped file, FTP link) with entire XAMPP package, I'm using, if you wish. Hope, this is something local, happening just for me, and not the general problem for all. |
IMO, its not yii bug, but php error. You cannot declare 2 class with same name. |
Fine. But, I'm not talking, that this is Yii bug. This issue is about handling this gracefully. If we are required to manually add In other words -- what is the reason for auto-declaring |
Please, explain your question. i dont get it. there is my generated migration. no <?php
use yii\db\Schema;
use yii\db\Migration;
class m150427_131430_dont_do_anything extends Migration
{
public function up()
{
}
public function down()
{
echo "m150427_131430_dont_do_anything cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
} |
Migration classes are NOT under any namespace, thus using classes from global namespace does not require 'use' statement. |
@klimov-paul OK, fine... But, then again... No matter, what is causing this problem, I can't imagine any professional framework that causes command-line to blow if user do anything. I reported this problem not to seek your explanation, what is causing this problem (but thank you, for explaining this to me), but to point you out, that you should at least consider, if there is any workaround for this? I know, that tracing or fixing this "problem" can't be beyond anything, you can do, but... then again, Yii2 is a professional framework and in a professional framework such extremely bad looking hangups shouldn't happen in any conditions. |
PHP parse errors and warnings are out of the framework scope I am afraid.
Are asking a wolkaround for PHP fatal error? I don't know any, sorry.
So if, for example, you miss a semicolon at the end of the statement or haven't enclose brackets correctly - framework should handle it somehow? Provide you a walk around? Are you serious? Or there is something else I have missed? |
@trejder yii has an errorhandler to deal with such errors, if your php crashes in some way this is a bug in php and yii can not do anything to fix this, this is another level. |
I think the best thing to do in this case is to trace down error to minimal example and submit it as PHP bug. Of course, if you have time for it since it doesn't sound like easy debug session. |
@klimov-paul Yes, I'm pretty serious. Please, don't make an equation between forgetting about missing semicolon and situation, when I should not declare @cebe I'm not sure, that Yii's error handler can trace redeclaration of class and deal with that in case of migration. If so, why then the console blows away on such obvious thing? @samdark This is neither PHP nor Yii bug. This is just a very special situation, where migrations are run in global namespace and thus does not require declaring All of you seems to be doing a really big problem out of something really small. In my opinion, a workaround, I'm asking for is to update
This would "solve" the problem once and for all. Even those programmer, like me, for which -- against to what @klimov-paul says -- this situation isn't obvious, would be informed about possible danger of redeclaring I have a very bad feeling, that you're, again and again, keep forgetting that Yii2 users are not always so experienced as you are and not always posses such knowledge as you are. For you, the fact that migrations are run in global namespace, is pretty obvious. For me it wasn't. And due to lack of above proposed comment and due to lack of my knowledge I wasted over half an hour on tracing what is going on and why my console gets fired hell? |
Just switch off debug mode.
Not only in migration file, also in view file and all file that not using namespace. Not only |
@trejder PHP crashes so it's PHP bug. Normally it should have produce a fatal error which is handled well by Yii. |
Everything you have shown so far seems proving, that this is my local problem only. However, I found it hard to believe. Mainly because:
I have asked a Stack Overflow question on this matter -- in case someone would like to follow this. |
Probably it's XAMPP problem and it should be updated since the bug could have been fixed already. If it's not, worth reporting to them. I'm not using XAMPP myself so can't confirm anything related to it. |
To my extreme surprise, adding
use Yii;
in the beginning of migration file kills command-line (Git for Windows) very badly.I think you may consider working-around this somehow.
I know, that
Yii
is available in migration and one does not / must not adduse Yii;
in the beginning of migration file. But, I'm pretty sure, you'd like to handle this situation a bit more gently, instead of firing user command-line console into one-way Mars mission, right? :>The text was updated successfully, but these errors were encountered: