Welcome Guest, Not a member yet? Register   Sign In
Class not found error with events
#1

I'm migrating a CI3 app to CI4, so naturally that means converting the hooks to events.

I have the following in app/Config/Events.php:

PHP Code:
Events::on('post_controller_constructor', ['Load_config''load_config']); 

In app/Events/Load_config.php I have:

PHP Code:
<?php

namespace App\Events;

use 
app\Libraries\MY_Migration;
use 
app\Models\Appconfig;
use 
CodeIgniter\Session\Session;
use 
Config\Services;

/**
 * @property my_migration migration;
 * @property session session;
 * @property appconfig appconfig;
 * @property mixed $migration_config
 * @property mixed $config
 */
class Load_config
{
    
/**
     * Loads configuration from database into App CI config and then applies those settings
     */
    
public function load_config()
    {
.
.


But when I load the application I'm greeted with "Error Class 'Load_config' not found". I'm assuming that this means that the event loader is not looking where I'm expecting it to look. A couple of questions come up:
- Where should classes formerly in the hooks folder be kept?
- Am I missing a reference in my event call that would cause the event loader to look in app/Events/ to find the class? I thought namespacing the class would take care of that, but perhaps I'm mistaken.
Reply


Messages In This Thread
Class not found error with events - by objecttothis - 11-18-2022, 03:57 AM
RE: Class not found error with events - by kenjis - 11-18-2022, 05:09 AM
RE: Class not found error with events - by kenjis - 11-20-2022, 02:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB