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

DevHarm's avatar

CodeIgniter to Laravel?

Hi Hi,

There may already be quite a few threads about this, but I can't really find the answer I'm looking for.

My previous application was built in CodeIgniter, but I notice that it occasionally becomes very confusing because I use quite a lot of plain PHP in the views. It works, but only I understand the code. There is a lot of plain PHP in the views for certain functions. However, I can move a lot of these functions to the Controller/Helper.

So I can do two things;

  • Rewrite/rebuild the application in CodeIgniter.
  • Invest some more time and transfer to Laraval.

What holds me back a bit is that I just throw CodeIgniter on my NGIX server (VPS) and it runs. Since I'm working alone on the project, Git isn't really interesting to me.

The big question is actually. Can I run Laravel on my (PLESK) server without having to work locally? Since the customer can then watch/test.

I have already tried a few things locally in combination with Inertia, I'll just stay away from there for now. This application does not have a front end and is basically an application for animals/inspections/shows/points system in combination with users.

Any advice? Since there are currently several Laravel versions/expansions; Lumen, Breeze etc. etc.

Thanks! Harm

0 likes
11 replies
martinbean's avatar

@devharm I’ve worked on numerous refactoring and re-platforming projects like this.

First, I’d completely ignore things like Inertia. You just want to concentrate on moving code from your CodeIgniter codebase to a Laravel one. I’d also strongly suggest you set up version control, given you’re going to be changing lots of files, and you really need confidence in being able to roll back if something hasn’t gone as you expected it to.

First, I’d complete this set-up tasks:

  1. Get your CodeIgniter checked into a Git repository as it is now.
  2. Get a deployment pipeline set up that can deploy your Git repository, to your server.

So, before you’ve even started on the Laravel conversion, you can confidently track changes and have those changes deployed to your server without manually FTP-ing or SSH-ing into your production server, or however you’re manually deploying currently. You can then focus on the re-platforming:

  1. Create a new Laravel application.
  2. Use the php artisan schema:dump command to get a “squash” migration that represents your database schema as it currently is.
  3. Update your nginx server configuration to first try and pass the request through Laravel’s public/index.php front controller, then to fall back to your CodeIgniter app’s front controller. This means that Laravel will attempt to handle requests first, and then to CodeIgniter if Laravel cannot handle the request. To start off with, all requests will end up going to CodeIgniter.
  4. Pick a simple page. Create a controller and route for it in your Laravel application, and copy the view over. Extract any plain PHP logic to appropriate classes. Delete that route and controller action from your CodeIgniter application.
  5. Create “smoke tests” in your Laravel app for this new route. Basically just assert that hitting the expected URL returns a 200 OK response. This will give you decent test coverage out of the box, and you can then flesh these tests out with more test cases and in-depth assertions at a later date.
  6. Deploy. The new route should be handled by the Laravel application rather than CodeIgniter.

If you keep re-doing points 4 through 6 (picking pages and lifting them into your Laravel application), you should find over time that your CodeIgniter codebase starts to decrease in size, and your Laravel application codebase increases in size. Once all requests are being handled by Laravel, you can then just discard what’s left of the CodeIgniter application, and go forward with Laravel solely.

Also meant to mention: be sure to create migrations for any database changes after you’ve ran the schema:dump command. You’ll also want to structure your directories on your server to avoid exposing any sensitive, server-side files. I’d recommend a structure like this:

.
├── codeigniter
│   ├── app
│   ├── system
│   ├── tests
│   └── writable
├── laravel
│   ├── app
│   ├── bootstrap
│   ├── config
│   ├── database
│   ├── resources
│   ├── routes
│   ├── storage
│   └── tests
└── public_html
    ├── index-codeigniter.php
    └── index-laravel.php

You will need to update the public paths for your CodeIgniter and Laravel applications since they slightly deviate from their norms. But it means your sensitive CodeIgniter and Laravel files will be outside of the public, web-accessible directory.

2 likes
DevHarm's avatar

@martinbean thanks for your reply and time.

That is also an option, but to be honest I would rather rewrite the code as some controllers are not logically constructed and that, in my opinion, is the disadvantage of HMVC. I don't know if that's stubborn or sensible.

I could indeed do this but I think the rewrite would literally be faster. You don't want to see the code in CodeIgniter haha ​​as the application had to be up and running quickly.

I will definitely take a look at version control (Git or whatever) and I think that is also quite easy to set up in PLESK. There is already a (Laravel) composer in there.

Let me just try a few things first because to be honest there is so much information on the internet but sometimes not exactly what I am looking for.

For me it is completely new to deploy websites in combination with version control since I always use "Upload On Save" in NetBeans/VSC/PhpStorm/whatever since it sometimes involves minor adjustments. Especially when you are still in development mode.

It's not that I'm ignoring your advice, but as I already indicated, a clean start is nice every now and then. Especially if I want to get to know Laravel better.

Thanks! Harm

martinbean's avatar
Level 80

@DevHarm You essentially are doing a “clean rewrite” though? You create a new Laravel application, and you move functionality into that new application piece by piece.

This way, anything “converted” to Laravel is handled by Laravel and removed from the CodeIgniter app at the same time. If you just created a new Laravel app, and worked on the two in tandem, you’d just get out of sync and the process take longer because you’ll get customer/management pressures to develop a feature, you haven’t moved it over to Laravel, so you then have to develop it in the old CodeIgniter app and still move it across at a later date any way. Whereas if you had the two running simultaneously, you can just write new code in the Laravel app, removing the need to write it or support it in the CodeIgniter app.

1 like
DevHarm's avatar

@martinbean The application in CodeIgniter is finished and no major maintenance is required because it works for now. Fortunately, the problem of me going out of sync does not apply. This was also done in consultation, so if a new function had to be added/small changes, it would still be manageable.

I understand what you mean and your idea behind it, but that application was written "quickly" which made it messy. The MVC pattern has become skewed. Sometimes there was more logic in the view than in the controller and that is exactly what I don't want haha.

I now have a Laravel (Breeze) environment running on a subdomain with Git. It took some time, research, trying and effort, but now I can finally continue.

The SSH connection in VSCode works, just some minor problems with Artisan. But I can also run it inside PLESK. But that's not something for here I guess.

Thanks for your thoughts and some kind of solution. I appreciate!

1 like
DevHarm's avatar

@tray2 Thanks for your comment. I am indeed familiar with this series and I watched it a while ago when Laravel 11 came out. It's not that I'm stuck in this, but I'm trying to find a working method that will still be relevant in the future. Since I am new to deploying/migrating.

1 like
DevHarm's avatar

Hey,

After trying a few things in Laravel I notice that I am still running into a few things.

In CodeIgniter I can work locally and use the external database (MariaDB) on the VPS where I could deploy my local files via Git. Is this even possible with Laravel?

I have been reading about this the last few weeks since Laravel is a bit stricter regarding ORM. In addition, I have seen and read quite a few tutorials but there are still a few things that are unclear to me.

Can I run Laravel + NodeJS locally on my Mac and use an external database? Or will I have to adjust my working method?

At the moment both my CodeIgniter and Laravel projects are running via Herd. That all works fine. The only thing that is so accessible to me is the way how easy it is to deploy CI.

Cheers!

martinbean's avatar

In CodeIgniter I can work locally and use the external database (MariaDB) on the VPS where I could deploy my local files via Git. Is this even possible with Laravel?

@devharm Laravel just uses PDO under the hood. You can connect to any database. But you should really be using a local database instead of connecting to an external one, for the sake of latency and not corrupting any important data.

Can I run Laravel + NodeJS locally on my Mac and use an external database? Or will I have to adjust my working method?

This seems to be pretty much the same question? Yes, you can run Laravel and Node.js locally on your Mac. Yes, you can use an external database. But should you? That’s another question (where the answer is usually “No” as mentioned above).

DevHarm's avatar

@martinbean Thanks for your reply.

It was indeed maybe a double question but maybe I should delve a bit more into database migration. I just want to code hehe :)

1 like
DevHarm's avatar

@Tray2 Thanks for your reply. Using Herd and DBngin indeed right now :)

1 like

Please or to participate in this conversation.