Welcome Guest, Not a member yet? Register   Sign In
  Relocating the app folder
Posted by: groovebird - 06-16-2022, 07:24 AM - Replies (6)


if i relocate the app folder the ROOTPATH will not be created correctly, because it is one folder above the app folder. This is not working if i relocate the app folder:

Root -> app -> this is working

Relocating the app folder:
Root -> codeigniter->app -> this is not working, because the ROOTPATH is codeigniter. This is not correct.

PHP Code:
// The path to the project root directory. Just above APPPATH.
if (! defined('ROOTPATH')) {
    define('ROOTPATH'realpath(APPPATH '../') . DIRECTORY_SEPARATOR);

I think relocating is not possible or is there any solution?

  Cannot update from 4.1.9 to 4.2.0
Posted by: b126 - 06-16-2022, 05:59 AM - Replies (2)

Dear support,
I am running CI 4.1.9 on PHP 7.3.33
Is it possible to upgrade to 4.2.0? composer update does nothing...
Thank you.

  Pre-query / OnConnect-query
Posted by: nowackipawel - 06-16-2022, 04:47 AM - Replies (1)

Hi there,
I do not have idea how I could achieve some kina of ON-CONNECT QUERY connection in the best way.
Let's say when CI is connecting to database I would like to send one query (i.e. set time_zone = "+00:00") I do not have any other option to do so on specific machine.
I do not want to repeat that query many times, just once when the connection is initialized(). I was thinking about some otpions like extending some classes of CI or add a support for that in Config file and CI itself and do the PR to the CI repo .... but the question is: Is there no option actually in CI to do so? I cannot find anything in the docs.

  session being destroyed
Posted by: michaelh613 - 06-16-2022, 02:48 AM - No Replies

Suddenly I am getting a strange error on some users
I am assuming something I have done in recent development has caused this yet I am having a hard time knowing where to look
I use db based sessions

session_start(): Failed to decode session object. Session has been destroyed /var/www/ci_system/system/libraries/Session/Session.php 143
The error comes from the library

  Catch data from CSP: report-uri
Posted by: Eko - 06-16-2022, 12:49 AM - Replies (2)

Hi guys how can I catch the data from CSP: report-uri? I already active it in the config App and set the report URL in ContentSecurityPolicy.php like this:

public $reportURI = '/csp-violation-report-endpoint';
at my Route.php I already define it like this:
$routes->add('csp-violation-report-endpoint', 'Home::csp');

And my controller like this:

    public function csp()
        log_message('info', 'CSP violation trigerred');
        $json_data = file_get_contents('php://input');

        $json_data = json_encode($json_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
        $current_domain = preg_replace('/www\./i', '', $_SERVER['SERVER_NAME']);
        $message = "The following Content-Security-Policy violation occurred on " .
            $current_domain . ":\n\n" .
            $json_data .
            "\n\nFurther CPS violations will be logged to the following log file, but no further email notifications will be sent until this log file is deleted:\n\n";

        log_message('error', $message);
But I don't get anything? is it something wrong or did I miss here? Thanks.

Question single page Master-Detail ( screenshot inside )
Posted by: Ahmed Haroon - 06-15-2022, 10:52 PM - Replies (2)

in an organization, a user showed me a Master-Detail screen, as per him it is created using CI4 by their vendor. can somebody help for How To's to achieve this working screen? please if possible, post a link to the guide as search results on google showed various links but nothing is like that " single screen Master-Detail " the Detail sections can have multiple records ( here in this screen is a limit of 10 rows to add, but i think this type of limit is not appropriate ) 

[Image: CI4-Master-Detail.jpg]

Question Using a third party class in CI4
Posted by: Sincere - 06-15-2022, 09:25 PM - Replies (7)

I want to use the influxdb-php class in CI4:
I tried calling the class from the controller using:

PHP Code:
use InfluxDB;
use \
use \

But no success. I installed it using composer:
composer require influxdb/influxdb-php

  CodeIgniter vs Laravel - speed and memory
Posted by: athosss - 06-15-2022, 04:22 PM - Replies (4)


My team and I are about to develop a government website that will receive millions of hits daily.

We are in doubt between CodeIgniter 4 and Laravel.

Please can someone show a benchmark of speed and memory usage for rendering a simple HTML page comparing the two frameworks.



Question Unable to add to array
Posted by: Sincere - 06-15-2022, 03:52 PM - Replies (2)

I've done this many times before: adding an array to an yet already existing array, but for some reason this isn't working now, and I'm out of clues:

PHP Code:
$influx_server_data = [];
$stats = [
                    'health'        =>  $health,
                    'total_live'    =>  $server->live_total,
//etc etc/
                    'mem_used'      =>  $server->system_stats->memory->used,
                    'mem_total'      =>  $server->system_stats->memory->total,

                //Influx Magic

                // Server influx data
                foreach($stats as $measurement => $value){
                    $influx_server_point = [$measurement//name of measurement
                        $value//measurement value
                        ['host' => $live_server->hostname'region' => $live_server->region], // optional tags
                    $influx_server_data $influx_server_data + [$influx_server_point];

But for some reason $influx_server_data will only have the array from the first run (health in this case). The first print_r confirms that the foreach works fine and shows the desired array for each run.
I'd be grateful for any insights!

  Custom Sort Query Syntax
Posted by: imranp - 06-15-2022, 01:08 PM - No Replies

Hey guys,
I'm hoping you can help me figure out the correct syntax for a query.

PHP Code:
$main_cat $this->db->from('categories')

This code returns an array of 15 objects (I am listing just two of the 15 below):

PHP Code:
    [0] => stdClass Object
            [id] => 4
[ecommerce_category_id] => 100
[last_modified] => 2022-04-12 13:35:18
[deleted] => 0
[hide_from_grid] => 0
[parent_id] => 
            [name] => Beverages
[image_id] => 
            [color] => 
            [system_category] => 0
[exclude_from_e_commerce] => 0
[category_info_popup] => 

    [1] => stdClass Object
            [id] => 8
[ecommerce_category_id] => 106
[last_modified] => 2022-04-12 13:48:57
[deleted] => 0
[hide_from_grid] => 0
[parent_id] => 
            [name] => Condiments
[image_id] => 
            [color] => 
            [system_category] => 0
[exclude_from_e_commerce] => 0
[category_info_popup] => 

By looping through the array, I am extracting the [name] for each member of the array:
PHP Code:
foreach ($main_cat as $key_main_cat => $values_main_cat)
    echo $values_main_cat->name;
    echo "<br>"
Which produces the following result:
Canned Fruits, Vegetables, & Meats
Soups, Broth, & Gravies
Pastas, Rice & Grains
Paper Products
Beans & Chili
Baking & Cooking
Baby Products
Health & Beauty
C-Store Supplies

I would like to sort this list in a custom order. I can think of two ways of doing this, but can't figure out the syntax for either method.

Method 1: Use Order_By condition in the query

I tried:

PHP Code:

but it didn't work. What would be the correct syntax?

Method 2: Sort the $main_cat array after the data has been populated

No idea how to do this.... probably simpler than method 1, but don't know how to sort the array using the custom order.

I appreciate your time and assistance!!

Welcome, Guest
You have to register before you can post on our site.



Latest Threads
Custom controller - reque...
by kenjis
2 hours ago
Codeigniter 4 Pagination ...
by kenjis
4 hours ago
Display a partial view ba...
by ikesela
11 hours ago
Working with uploaded fil...
by Kordianz
Today, 01:48 AM
I need to know the recomm...
by InsiteFX
Today, 12:24 AM
CLI gives errors on share...
by kenjis
Yesterday, 08:55 PM
AJAX / Post / delete reco...
by spreaderman
Yesterday, 08:00 PM
Codeigniter 4.2 Auto Rout...
by Gary
Yesterday, 02:33 PM
How To Optimise Controlle...
by includebeer
Yesterday, 11:23 AM
Chrome/Firefox et al Rout...
by Gary
Yesterday, 09:13 AM

Forum Statistics
» Members: 37,535
» Latest member: autoemc
» Forum threads: 75,090
» Forum posts: 366,158

Full Statistics

Search Forums

(Advanced Search)

Theme © iAndrew 2016 - Forum software by © MyBB