How To Setup A Codeigniter 4 Project On Infinityfree

CodeIgniter is a powerful PHP framework with a very small footprint, built for developers who need a simple and elegant toolkit to create full-featured web applications.
CodeIgniter

Creating a full PHP website yourself is hard, and that’s why there are PHP Frameworks.

A PHP framework is a platform for creating PHP web applications. It contains libraries with pre-packaged functions and classes and, more often than not, elements for software design pattern realization.

Laravel is a popular PHP Framework, but you should have shell access to the server to get the most out of it, and you don’t have shell access on InfinityFree.

CodeIgniter on the other hand, doesn’t require shell access at all. So in my opinion, CodeIgniter is the best PHP Frakework to use with InfinityFree. In this post, I will explain how to install CodeIgniter 4 on your InfinityFree account.

How to install CodeIgniter 4 on InfinityFree

  • Step 1 - Download CodeIgniter 4 Source Code (zip) and extract the zip.
  • Step 2 - Extract the zip to your project folder root. Say D:\Dev
  • Step 3 - Rename the folder framework-4.0.4 to your project name. Example: MyProject
  • Step 4 - Go inside the MyProject Folder, and open app\Config\App.php in a text editor, and change $baseUrl to your domain (or subdomain) with a trailing slash.
  • Step 5 - CodeIgniter 4 requires you to “point” the server to the public folder. To do this, create a .htaccess file in the project root, ie. MyProject, and add the following into it:
RewriteRule (.*) /public/$1 [QSA,L]
  • Step 6 - Finally, upload everything inside MyProject to your htdocs folder via FTP.

How It Looks

When you go to your website, you will see something like this:

To customize your website, see the CodeIgniter Docs

Example Site

My website, hosted with InfinityFree is completely made with CodeIgniter - https://jnote.ml

Avoiding getting suspended

CodeIgniter can sometimes use a lot of resources if your code is bad. To protect agaainst this, I recommend you to use a Local PHP Development Server on your computer for testing and only upload to infinityfree when you are done testing.

To do this, you can run the following command in a terminal after cd ing to your project folder:

php spark serve

and access http://localhost:8080 on your computer.

5 Likes

Just checking: did you run into any problems setting up things like database configuration? I still have a task on my list to look into a possible hosting restriction related to it, so I’m curious if you found out something like that.

1 Like

First of all sorry for the late reply :grinning_face_with_smiling_eyes:

I used a SQLite database and the only trouble I ran into while connecting was specifying the correct driver. I tried to use sqlite3 instead of SQLite3 (the driver name was case-sensitive).

3 Likes