Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4 - Using renameColumn in controller

I want to use artisan migration within my controller, like this

echo '<br>init migrate:install...';
Artisan::call('migrate');
echo 'done migrate:install';

It works fine for all my table creations and etc. But there are problems when I try to use $table->renameColumn

Laravel doc said I need to include doctrine/dbal, but how? I have tried use Doctrine\DBAL\Driver\PDOMySql\Driver; but no luck.

FYI i cannot use CLI, my host doesn't provide any CLI to me.

Here is my error

Symfony \ Component \ Debug \ Exception \ FatalErrorException
Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found

UPDATE

Same error when using terminal to migrate

SECOND UPDATE

An Example of migration code at app/database/migrations

use Illuminate\Database\Migrations\Migration;

class UpdatePostsTable extends Migration {

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('user', function($table)
        {
            $table->renameColumn('fullname', 'full_name');
        });
    }
}
like image 714
Loonb Avatar asked Feb 10 '14 17:02

Loonb


2 Answers

Add the doctrine/dbal dependency to your composer.json file.

For more information, it's on the very bottom of this page in the documentation.

http://laravel.com/docs/releases

like image 179
user1669496 Avatar answered Sep 22 '22 00:09

user1669496


Add doctrine/dbal dependency to your composer.json file, like

"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.1.*",
    "illuminate/html": "5.*",
    "doctrine/dbal": "~2.3"
},

Then update composer using sudo composer update command, this will work.

like image 37
shijinmon Pallikal Avatar answered Sep 25 '22 00:09

shijinmon Pallikal