Questions tagged [codeigniter-4]

CodeIgniter 4.x is the latest major version tree of the popular PHP-based framework. CodeIgniter is an Application Development Framework - a toolkit - primarily for people who build websites using PHP. Please refer to the [codeigniter] tag for more information.

CodeIgniter 4.0.3 is the latest release, targeted for PHP7+ only and is not intended to be backwards-compatible with previous CodeIgniter versions.


What is CodeIgniter?

CodeIgniter is an Application Development Framework - a toolkit - for people who build websites using PHP. Its goal is to enable you to develop projects much faster than you could if you were writing code from scratch by providing a rich set of libraries for commonly needed tasks, as well as a simple interface and logical structure to access these libraries. CodeIgniter lets you creatively focus on your project by minimizing the amount of code needed for a given task.

Codeigniter 4.x is the latest major version tree of the framework. The project (originally from EllisLab) has been completely rewritten and is maintained on GitHub by the British Columbia Institute of Technology.


Please refer to the tag for more information.

1234 questions
3
votes
2 answers

How to insert multiple rows in mysql database with codeigniter 4 framework?

I am trying to make a web application using CodeIgniter 4 framework where I need to insert multiple rows in a single submit. I tried with codeIgniter 4 query builder insertBatch and got this error while inserting multiple rows in the MySQL…
Monayem Islam
  • 294
  • 3
  • 15
3
votes
1 answer

Code Igniter 4 Default pagination using Model Class has no order by and Join

$postModel = new \App\Models\PostModel(); $pager = \Config\Services::pager(); $post = $postModel->orderBy('dteCreatedDate', 'DESC')->findAll(); $data = [ 'post' => $postModel->paginate(2,'post'), 'pager' => $postModel->pager …
guradio
  • 15,524
  • 4
  • 36
  • 57
3
votes
1 answer

Session variable not printing in view in Codeigniter 4

in codeigniter 4 I have tried to print the session variable in view using $session->get('item'); and $session->item as well but unfortunately it does not print. But same variables are printed using $_SESSION global variable. can any one guide how to…
Zaman Fakhar
  • 31
  • 1
  • 2
3
votes
6 answers

Setting Dynamic base URL in CodeIgniter 4.0.2

I am migrating my project from CodeIgniter 3 to CodeIgniter 4. I am getting confused for the new structure of the framework. So here's my problem, I am setting my base url in App.php to: protected $proj_root=…
Roshan
  • 786
  • 1
  • 9
  • 20
3
votes
1 answer

CI4 Getting started issues

Decide to give the newly released CI4 a try. Ubuntu operating system with php 7.4.3. Following the docs at https://codeigniter4.github.io/userguide/installation/index.html composer create-project codeigniter4/appstarter c400 cd c400 # Not sure if…
Cerad
  • 48,157
  • 8
  • 90
  • 92
3
votes
6 answers

how to display uploaded images in codeigniter 4

In Codeigniter 4, how to display uploaded images. Is there any permission needed to be given? I uploaded images in writable/uploads/avatar in CI4 project when I check on the inspect element and copy the link and paste on the browser the images…
Durai Raj
  • 47
  • 1
  • 1
  • 8
3
votes
3 answers

Codeigniter 4 Current/Active Controller

In Codeigniter 3 is possible to get current active class and method with this code: $active_controller = $this->router->fetch_class(); $active_function = $this->router->fetch_method(); Are there such functions in Codeigniter 4?
Tsefo
  • 409
  • 4
  • 15
3
votes
4 answers

Could not find package codeigniter4/framework with stability stable

I'm doing exactly like what is suggested in the official documentation. composer create-project codeigniter4/framework However, I'm getting this error instead: [InvalidArgumentException] Could not find package codeigniter4/framework with stability…
Rangka Kacang
  • 327
  • 1
  • 5
  • 12
2
votes
1 answer

Nesting Groups of Filters not working in CodeIgniter 4

I'm having hard time to configure nested groups in CI 4. I'm trying to configure the access to routes passing thru a group of filters to authenticate and validate the data that i'm using in the controller. Here's a example of the…
2
votes
1 answer

Codeigniter 4, call a controller method in a seeder

Morning guys, I'm searching on how to call a function of a controller in my seeder file. Account Controller public function createCompte() { //generate an account number return $numcompte; } } seeder public function run(){ …
2
votes
1 answer

Fatal error: Declaration of Monolog\Logger::emergency(Stringable|string $message, array $context = []):[]):

i'm using codeigniter 4 and i try to implement Login with Google. so far so good until i got this error when i try to get the result. here the error message: Fatal error: Declaration of Monolog\Logger::emergency(Stringable|string $message, array…
2
votes
0 answers

Codeigniter 4 restful api return cors error when using PUT and DELETE method

On the frontend I'm using react and sending the request via axios. import axios from "axios"; import { getToken } from "./auth"; const api = axios.create({ baseURL: import.meta.env.VITE_API_URL, }); export default api; And in backend i'm using…
Trimander
  • 21
  • 2
2
votes
2 answers

Install Shield for CodeIgniter 4 without composer

I like using CodeIgniter because I don't need composer. However, I am trying to install Shield for CodeIgniter (Authentication and Authorization for CodeIgniter 4) and I don't find how to install it without Composer. Is it even possible?
user1314836
  • 219
  • 1
  • 4
  • 14
2
votes
0 answers

php spark serve Uncaught Error: Call to undefined function CodeIgniter\CLI\mb_strpos()

I'm new to PHP and trying to open the CodeIgniter 4 welcome page by using localhost (I don't have any server programs like XAMPP since it's a company computer and PHP works fine with its built-in server.) When I try to run the command: php spark…
2
votes
1 answer

getenv() is some times returning false in CodeIgniter 4. Why?

I am loading table data fetched using Ajax in a table with datatables. The logic fetches some value from the .env file using getenv() function. This getenv() is returning false only some of the times and otherwise not. I tried opening the URL (HTTP…
Sarvap Praharanayuthan
  • 4,212
  • 7
  • 47
  • 72