Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

anjanesh's avatar

CodeIgniter 3 to Laravel 10

I have a fairly medium sized CodeIgniter3 codebase and now I want it migrated to Laravel 10. Is it possible to create the same models in Laravel retaining the table structure ?

How do I got about migration of users table ?

0 likes
8 replies
LaryAI's avatar
Level 58

Migrating from CodeIgniter 3 to Laravel 10 is possible, but it will require some manual work. You will need to create the same models in Laravel, and you can do this by creating a new migration file for each table in your CodeIgniter database.

For example, if you have a users table in your CodeIgniter database, you can create a new migration file in Laravel with the following code:

Schema::create('users', function (Blueprint $table) {
    $table->id();
    $table->string('name');
    $table->string('email')->unique();
    $table->timestamps();
});

This will create a new users table in your Laravel database with the same structure as your CodeIgniter database. You can then add any additional fields or constraints to the table as needed.

Once you have created the migration files for all of your tables, you can then use the Laravel Artisan command php artisan migrate to migrate the data from your CodeIgniter database to your Laravel database.

Hope this helps!

jlrdw's avatar

The documentation clearly states you can have custom keys and foreign keys if necessary, if that is the problem:

If you would like the relationship to use a primary key value other than id or your model's $primaryKey property, you may pass a third argument to the hasOne method:

Same for all relations:

Reference:

https://laravel.com/docs/10.x/eloquent-relationships

But the question is still vague. Of course you can do anything in laravel as codeigniter. But much will be new code (a rewrite).

anjanesh's avatar

I'm ready to re-write the code base from scratch but the database is live for about 5+ years which is about 5GB.

ravia259's avatar

@anjanesh I am at similar crossroads to migrate my CI codebase. I am trying to move to Laravel, but open for other frameworks. How do you rate your experience to move to Django?

Thanks for your response.

Thanks Ravi

anjanesh's avatar

@ravia259 I had to take help from the coder who originally wrote the CI code base.

Please or to participate in this conversation.