Skip to content

Tag: codeigniter-4

How to use foreign keys migration with database migrations. (errno: 150 “Foreign key constraint is incorrectly formed”)?

CodeIgniter 4 has a handy solution for migrations and seeders. Without the usage of foreign keys, everything is working perfectly. But when I use foreign keys I get “Unable to add foreign key”. This is because of the order of happenings: Quick example: So when I now run php spark migrate or php spark migrate:refresh the foreign key can not

CodeIgniter 4: Pass $data to the View file

Can someone help me with this? I can’t figure out on how can I show the results on the View file. I tried using $this->load->view(‘list-logs’,$data); but it shows the error Call to a member function view() on null. CONTROLLER VIEW Answer if you use CodeIgniter 4 then you must call the view ont controller like this:

Codeigniter 4 localization issue with UTF-8 characters

The context I am trying to perform a lemmatization of some texts and I figured out that I can use CI4 localization for this. Basically I created some files in AppLanguagesro-RO and I am “translating” the words to their linguistic root. The language files are encoded in UTF-8 (I checked it on the server with file -i command). PHP has

Setting Parameters in CI4s redirecting function

is there any possible way to send parameters within the redirection function from Codeigniter 4? Important, it is a named route: And i want to do a redirect like this: this works fine: this would be nice, if it works: or Why? I have HMVC and I would like to name every module with the same routes but different functions

Codeigniter4 how to call parent controller’s constructor from derived class constructor

In Codeignter 4 we can’t use constructor in BaseController. But the method initController() will do it. But how can call this method from derived controller’s constructor? My question is that BaseController::is_allowed() method will do all basic features that are commonly useful for all derived controller classes. But to work BaseController::is_allowed() , BaseController::__construct() should be execute before this. But as in

How to use CI4 parser service to render view from module

I’m trying to load views from module folder, since CI always look for views in App/View folder, how this can be overwritten to give complete path from ROOTPATH instead of APPPATH/Views Error CodeIgniterViewExceptionsViewException Invalid file: {path/to/project}/app/Config/../Views/modules/PluginName/Views/index.php Answer You are using a path relative to the default Views path. You could either: 1. Edit the line below in your Config/Path.php file