CodeIgniter Forums

Full Version: HTML Table Class new error!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Please help! Added lines to controller method:
PHP Code:
$table = new \CodeIgniter\View\Table();

$data = array(


error:  Class 'CodeIgniter\View\Table' not found

What use to add?
check here

load the library in controller : $this->load->library('table');

and the rest on view or what ever you like
$data = array(
array('Name', 'Color', 'Size'),
array('Fred', 'Blue', 'Small'),
array('Mary', 'Red', 'Large'),
array('John', 'Green', 'Medium')

echo $this->table->generate($data);

i just tested it with no errors

P.S. i dont know why you want this one $table = new \CodeIgniter\View\Table(); Tongue
This is good in CI3! I try it in CI4 and there such code does not work! Help me please!
@mboutos This *is* the CodeIgniter 4 support subforum, hence the namespaced HTML Table usage ...

@videoproc Your usage looks right out of the user guide, and should work.

Need a bit more info for context ...
where in your controller is this happening? is it perhaps outside of any method?
I just tried it in the Home Controller index method and it worked fine on my system.

Something else must be wrong on your end.

I' m using the latest developers version of CI 4.


Name    Color    Size
Fred    Blue    Small
Mary    Red    Large
John    Green    Medium
Make sure you are running php 7.2+ it is required.
Use php 7.3
My code:
PHP Code:
<?php namespace App\Controllers;


Cron extends BaseController
    protected function 
$table = new \CodeIgniter\View\Table();
$data = array(
    public function 
       $nh_method 'nh_'.$method;

Errors log:
<?php defined('SYSTEMPATH') || exit('No direct script access allowed'); ?>

CRITICAL - 17.07.2019 09:17:23 --> Class 'CodeIgniter\View\Table' not found
#0 C:\_OpenServer\OSPanel\domains\\app\Controllers\Cron.php(59): App\Controllers\Cron->nh_1min(Array)
#1 C:\_OpenServer\OSPanel\domains\\system\CodeIgniter.php(829): App\Controllers\Cron->_remap('1min')
#2 C:\_OpenServer\OSPanel\domains\\system\CodeIgniter.php(330): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Cron))
#3 C:\_OpenServer\OSPanel\domains\\system\CodeIgniter.php(240): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)
#4 C:\_OpenServer\OSPanel\domains\\public\index.php(45): CodeIgniter\CodeIgniter->run()
#5 {main}
Updated CI to the latest version! It was beta 4.2. It all worked! I apologize for your concern!
No problem, that's what we are here for.