From CodeIgniter3 to Laravel. An outline of a package management system that may be a hurdle when jumping into a framework with a different culture

Aug 30, 2020 PHP CodeIgniter Composer Laravel CodeIgniter3


This time, I would like to set up a more advanced (practical) specification example to contrast CodeIgniter and Laravel code.

Specifically, I would like to create a page that incorporates CSS and JS, but I will leave a concrete code introduction to the next article, this time about a more basic ** “package management system” ** Touch.

I would like to make every effort so that it doesn’t get too difficult all at once, but compared to the last time, the hurdles have become much higher, and I feel like I’m chilling and sweating how accurately my uncle’s verbalization ability can express me (pressure pressure).

This is Masakari’s welcome project (Please tell us a lot).

Two package management systems appearing in #Laravel

I was wondering when to speak, but I will have to write it someday, so I will use the current timing.

CodeIgniter, which has the advantage of being “lightweight”, is more like a set of files that is simply a folder structure rather than a framework. (If you say that, all frameworks in the world However, it can be said that it is a “collection of files”…).

On the other hand, although Laravel is also a “collection of files”, the major difference is that the “package management system” ** is frequently used as a standard mechanism.

*I think that it is possible to develop with Laravel without using the package management system at all, but I think that there is almost no merit (it will be difficult only).

*“What is the package management system?” is not included in the description scope of this article because there are many excellent articles.

And, surprisingly, Laravel has two package management systems**:

It’s not about using one or the other, but the role is different in the first place (backend side or frontend side).

Let’s take a closer look below.

Create new project

CodeIgniter can be downloaded as a zip from the official website.

It is the stance that the developer accesses the official website with a browser and acquires the set of files from there.


On the other hand, **Laravel uses a package management system called Composer to generate **a set of project files from the command line.

For example, to generate a project named example, run the following command:

composer create-project --prefer-dist laravel/laravel example

If you’re used to CodeIgniter, you’ll end up with the urge to add or move files by hand, but that’s the point where patience is the entrance to the Laravel culture.

Finally, recap:

Process CodeIgniter Laravel
Get a set of templates Download the zip from the official site Get via the Composer command

Add PHP file

When adding a new PHP file (eg controller) with CodeIgniter, shortcuts like Ctrl + C and Ctrl + P that everyone loves were very useful, just like copying and pasting a text file.

On the other hand, in Laravel, when adding a new PHP file (eg controller), it is executed on the command line using the package management system Composer.

For example, to create a controller called MyFirstController, run the following command:

php artisan make:controller MyFirstController

In Laravel, you can also create a new PHP file with Ctrl + C and Ctrl + P (eg you can copy it from an existing class), but it is troublesome to rewrite the contents of the copied file yourself. Is not a very smart method.

Finally, recap:

Process CodeIgniter Laravel
Add PHP file Manually supported by Ctrl + C and Ctrl + P Create via Composer command

Add CSS / JS files

Consider the case of generating front-end assets such as CSS / JS files.

With CodeIgniter, which is as simple as a collection of files, all you have to do is save CSS and JS to a specified folder (and then load them in the view’s <head></head> section).

Even in Laravel, the style of CodeIgniter era of saving CSS / JS in a predetermined folder is available.

On the other hand, Laravel also offers the option of using another package management system, Laravel Mix.

If you write it roughly, it will play the following roles.

On the command line, you can use npm run dev to pack it into a format that is easy to debug (easy to interpret by human eyes) in the development environment.

On the other hand, npm run production will pack it in a format suitable for release (excluding spaces and line breaks, suitable for computer interpretation, and very small in file size).

One thing to emphasize is that **Laravel Mix is a package management system that has’Laravel’ in its name but can be used with or without Laravel.

In other words, CodeIgniter can still utilize Laravel Mix.

Finally, recap:

Process CodeIgniter Laravel
Add CSS / JS files Manually save to a specified folder Use Laravel Mix


It’s quite a rush, but if you can understand that file management that was done manually in CodeIgniter can be done with the command line in Laravel, the release purpose of this article is achieved. It was.

In fact, I feel that it is also the concept of Laravel that the command line makes good use of the package management system and allows the engineer to focus on the work they should be focusing on.

Next time, I’d like to see how to embed front-end assets (CSS / JS) using Laravel while comparing with CodeIgniter while actually operating the package management system.