将Laravel升级到4.2后,Artisan::call('migrate')无法正常工作 - php

我正在使用Artisan :: call('migrate');在Laravel控制器方法中运行,并且在Laravel版本为4.1时可以使用。使用composer update命令更新Laravel(并在composer.js中设置“ laravel / framework”:“ 4.2。*”)后,此控制器方法(因为这是其中的唯一命令)不再起作用。

我什至在中在/app/config/app.php中添加了'cipher'=> MCRYPT_RIJNDAEL_256

那已经发生了:http://laravel.com/docs/upgrade#upgrade-4.2

当我将Artisan :: call('migrate')放入try / catch块控制器时,如下所示:

public function ArtMigr(){
    try {
            Artisan::call('migrate');
        } catch (Exception $e) {
            echo $e;
        }   

}

我收到以下错误:

消息“使用未定义的常量”的异常“ ErrorException”
STDIN-假设为“ STDIN”
D:\ htdocs \ artisan_error \ vendor \ symfony \ console \ Symfony \ Component \ Console \ Helper \ QuestionHelper.php:112
堆栈跟踪:#0
D:\ htdocs \ artisan_error \ vendor \ symfony \ console \ Symfony \ Component \ Console \ Helper \ QuestionHelper.php(112):
Illuminate \ Exception \ Handler-> handleError(8,'使用未定义...',
'D:\ htdocs \ artis ...',112,数组)#1
D:\ htdocs \ artisan_error \ vendor \ symfony \ console \ Symfony \ Component \ Console \ Helper \ QuestionHelper.php(49):
Symfony \ Component \ Console \ Helper \ QuestionHelper-> doAsk(Object(Symfony \ Component \ Console \ Output \ NullOutput),
对象(Symfony \ Component \ Console \ Question \ ConfirmationQuestion))#2
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Console \ Command.php(186):
Symfony \ Component \ Console \ Helper \ QuestionHelper->询问(Object(Symfony \ Component \ Console \ Input \ ArrayInput),
对象(Symfony \ Component \ Console \ Output \ NullOutput),
对象(Symfony \ Component \ Console \ Question \ ConfirmationQuestion))#3
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Console \ ConfirmableTrait.php(21):
Illuminate \ Console \ Command-> confirm('你真的很...')#4
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Database \ Console \ Migrations \ MigrateCommand.php(59):
照亮\ Database \ Console \ Migrations \ MigrateCommand-> confirmToProceed()

5 D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Console \ Command.php(112):

照亮\ Database \ Console \ Migrations \ MigrateCommand-> fire()#6
D:\ htdocs \ artisan_error \ vendor \ symfony \ console \ Symfony \ Component \ Console \ Command \ Command.php(252):
Illuminate \ Console \ Command-> execute(Object(Symfony \ Component \ Console \ Input \ ArrayInput),
对象(Symfony \ Component \ Console \ Output \ NullOutput))#7
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Console \ Command.php(100):
Symfony \ Component \ Console \ Command \ Command-> run(Object(Symfony \ Component \ Console \ Input \ ArrayInput),
对象(Symfony \ Component \ Console \ Output \ NullOutput))#8
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Console \ Application.php(96):
Illuminate \ Console \ Command-> run(Object(Symfony \ Component \ Console \ Input \ ArrayInput),
Object(Symfony \ Component \ Console \ Output \ NullOutput))#9 [内部
函数]:Illuminate \ Console \ Application-> call('migrate')#10
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Artisan.php(57):
call_user_func_array(Array,Array)#11
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Support \ Facades \ Facade.php(208):
Illuminate \ Foundation \ Artisan-> __ call('call',Array)#12
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Support \ Facades \ Facade.php(208):
照亮\ Foundation \ Artisan-> call('migrate')#13
D:\ htdocs \ artisan_error \ app \ controllers \ HomeController.php(160):
照亮\支持\外观\门面:: __ callStatic('call',Array)#14
D:\ htdocs \ artisan_error \ app \ controllers \ HomeController.php(160):
照亮\ Support \ Facades \ Artisan :: call('migrate')#15
D:\ htdocs \ artisan_error \ app \ controllers \ HomeController.php(145):
HomeController-> InstallDatabaseStructure()#16
D:\ htdocs \ artisan_error \ app \ controllers \ HomeController.php(127):
HomeController-> WriteDatabaseCredentials('localhost',
'laravel-aplikac ...','root','')#17 [内部功能]:
HomeController-> postTestDatabaseConnection()#18
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Controller.php(231):
call_user_func_array(Array,Array)#19
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ ControllerDispatcher.php(93):
照亮\ Routing \ Controller-> callAction('postTestDatabas ...',数组)

20 D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ ControllerDispatcher.php(62):

照亮\ Routing \ ControllerDispatcher-> call(Object(HomeController),
对象(Illuminate \ Routing \ Route),'postTestDatabas ...')#21
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Router.php(930):
Illuminate \ Routing \ ControllerDispatcher-> dispatch(Object(Illuminate \ Routing \ Route),
对象(Illuminate \ Http \ Request),'HomeController',
'postTestDatabas ...')#22 [内部功能]:
Illuminate \ Routing \ Router-> Illuminate \ Routing {关闭}()#23
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Route.php(105):call_user_func_array(Object(Closure),Array)#24
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Router.php(996):
Illuminate \ Routing \ Route-> run(Object(Illuminate \ Http \ Request))#25
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Routing \ Router.php(964):
Illuminate \ Routing \ Router-> dispatchToRoute(Object(Illuminate \ Http \ Request))

26 D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Application.php(738):

Illuminate \ Routing \ Router-> dispatch(Object(Illuminate \ Http \ Request))

27 D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Application.php(708):

Illuminate \ Foundation \ Application-> dispatch(Object(Illuminate \ Http \ Request))

28 D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Session \ Middleware.php(72):

Illuminate \ Foundation \ Application-> handle(Object(Illuminate \ Http \ Request),
1,正确)#29
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Cookie \ Queue.php(47):
Illuminate \ Session \ Middleware-> handle(Object(Illuminate \ Http \ Request),
1,正确)#30
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Cookie \ Guard.php(51):
Illuminate \ Cookie \ Queue-> handle(Object(Illuminate \ Http \ Request),1,
正确)#31
D:\ htdocs \ artisan_error \ vendor \ stack \ builder \ src \ Stack \ StackedHttpKernel.php(23):
Illuminate \ Cookie \ Guard-> handle(Object(Illuminate \ Http \ Request),1,
正确)#32
D:\ htdocs \ artisan_error \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Application.php(606):
Stack \ StackedHttpKernel-> handle(Object(Illuminate \ Http \ Request))#33
D:\ htdocs \ artisan_error \ public \ index.php(49):
Illuminate \ Foundation \ Application-> run()#34 {main}

一切都在我这边做得好吗?

composer.js包含:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "laravel/framework": "4.2.*",
        "way/generators": "dev-master"
    },
    "autoload": {
        "classmap": [
            "app/commands",
            "app/controllers",
            "app/models",
            "app/database/migrations",
            "app/database/seeds",
            "app/tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "stable"
}

参考方案

是的,最新版本实际上有问题,所有以前的源均不起作用,应使用:

Artisan::call('migrate', array('--force' => true));

经过测试,工作正常。

PHP:不推荐使用password_hash的'salt'选项 - php

我正在使用密码哈希进行注册。我需要手动创建Salt,以下是我使用的代码:$options = [ 'cost' => 11, 'salt' => mcrypt_create_iv(22, MCRYPT_DEV_URANDOM) ]; $password = password_hash( $this->…

PHP-全局变量的性能和内存问题 - php

假设情况:我在php中运行一个复杂的站点,并且我使用了很多全局变量。我可以将变量存储在现有的全局范围内,例如$_REQUEST['userInfo'],$_REQUEST['foo']和$_REQUEST['bar']等,然后将许多不同的内容放入请求范围内(这将是适当的用法,因为这些数据指的是要求自…

PHP strtotime困境 - php

有人可以解释为什么这在我的服务器上输出为true吗?date_default_timezone_set('Europe/Bucharest'); var_dump( strtotime('29.03.2015 03:00', time()) === strtotime('29.03.2015 04:00�…

php-casperjs获取内部文本 - php

我正在为casperjs使用php包装器-https://github.com/alwex/php-casperjs我正在网上自动化一些重复的工作,我需要访问一个项目的innerText,但是我尚不清楚如何从casperjs浏览器访问dom。我认为在js中我会var arr = document.querySelector('label.input…

PHP Laravel从另一个驱动器读取文件 - php

我目前正在学习Laravel。我想知道是否有一种方法可以在Laravel中使用Storage::从另一个硬盘访问文件(使用Windows)。例如,我在驱动器C:上安装了带有Laravel的Xampp,但是我想访问网站目录之外的E:上的文件。我试过使用Storage::files('E:')和File::files('E:…