Laravel 5:Migration-Route - Artisan :: call('migrate',array(' - force'=> true))停止

问题描述:

I have an migration-route in my application, the current output is:

init migrate:install...done migrate:install
init with tables migrations...

Now it stops. But the output should continue. Heres the route:

Route::get('/migrate', function () {
    try {
        try {
            echo '<br>init migrate:install...';
            Artisan::call('migrate:install');
            echo 'done migrate:install';
        } catch (Exception $e) {
            echo 'allready installed';
        }

        echo '<br>init with tables migrations...';
        Artisan::call('migrate', array('--force' => true)); // here it stops via browser
        echo 'done with migrations';

        echo '<br>clear view cache...';
        $cachedViewsDirectory = app('path.storage').'/framework/views/';

        if ($handle = opendir($cachedViewsDirectory)) {
            while (false !== ($entry = readdir($handle))) {
                if(strstr($entry, '.')) continue;

                @unlink($cachedViewsDirectory . $entry);
            }

            closedir($handle);
        }
        echo 'all view cache cleared';

        return redirect()->route('backend::dashboard');
    } catch (Exception $e) {
        Response::make($e->getMessage(), 500);
    }
});

While accessing the Shell and run the migration it will work:

-bash-4.2$ /opt/plesk/php/5.6/bin/php artisan migrate
**************************************
*     Application In Production!     *
**************************************

 Do you really wish to run this command? (yes/no) [no]:
 > yes

Migrated: 2016_08_23_194102_import_old_data
Migrated: 2016_08_25_080129_import_old_adresses
Migrated: 2016_08_25_080801_import_oldname_to_accountholder

Why it doesn't work from route?

UPDATE

The Apache Log shows "GET /migrate HTTP/1.0" with return state 200, so its HTTP OK.

Also in Browser DEV tools no errors.

UPDATE 2

Also laravel.log is empty. No new entry during call to migration-route.

OK I got it run.

Original migration (wich may would been usefull if I idiot had posted it)

/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    // Load data to be imported.
    $oldOrders = json_decode(File::get('storage/olddata.json'), TRUE);

    // Update.
    foreach ($oldOrders as $rawOrder) {
        /* @var \App\Order $order */
        $order = \App\Order::find(intval($rawOrder['id']));

        // Check whether order is payed.
        if ($order->isPayed() === FALSE && floatval($rawOrder["payedAmount"]) != 0) {
            /* @var \App\Payment $payment */
            $payment = new \App\Payment();

            $payment->order_id = $order->id;
            $payment->amount = $rawOrder["payedAmount"];
            $payment->method = $rawOrder["paymentMethod"];

            $payment->save();
        }
    }
}

And the migration now

/**
 * Run the migrations.
 *
 * @return void
 */
public function up()
{
    // Load data to be imported.
    $oldOrders = json_decode(File::get(base_path('storage/olddata.json')), TRUE);

    // Update.
    foreach ($oldOrders as $rawOrder) {
        /* @var \App\Order $order */
        $order = \App\Order::find(intval($rawOrder['id']));

        // Check whether order is payed.
        if ($order->isPayed() === FALSE && floatval($rawOrder["payedAmount"]) != 0) {
            /* @var \App\Payment $payment */
            $payment = new \App\Payment();

            $payment->order_id = $order->id;
            $payment->amount = $rawOrder["payedAmount"];
            $payment->method = $rawOrder["paymentMethod"];

            $payment->save();
        }
    }
}

On local environment I migrated from shell. The startpoint there is /. But with the route the startpoint seems to be something else and File::get threw an Exception. But (whyever) it never got logged. I added try{}catch(\Exception $e){} around the migration and saw the error.

post the error, open dev tools > network tab, or apache error logs