Welcome Guest, Not a member yet? Register   Sign In
Factories in docs explained badly

I'm trying to figure out how to use factories in CI4.
But the documentation is not up to par on explaining it.

For example here:https://codeigniter.com/user_guide/conce...ories.html


namespace Config;

use CodeIgniter\Config\Factory as BaseFactory;
use CodeIgniter\Filters\FilterInterface;

class Factories extends BaseFactory
    public $filters = [
        'instanceOf' => FilterInterface::class,

This example seems to be a mix of the Config/Factory.php and Factories.php files mentioned above the code.

Anyone here that can give a working example? Both files mentioned, and where do I place the Factories.php file? in app/Factories ?
Any help would be appreciated. Thanks.

$data = Factories::myfactoryfunction('Data');

How do I create a new Factory function like above?
Shouldn't be too hard i guess, but I can't figure it out by reading the documentation.
And I haven't found any examples searching the web. Any help appreciated.

Yes, it is difficult to understand how to use Factories.

How about this?
PHP Code:
$data Factories::myfactoryfunction(Data::class); 

+1 to this, documentation basically explains nothing on this topic Undecided

Hello guys,

I found how to do.
Create the file app/Config/Factory.php where to set these options. Then check that the namespace is Config such as te other config file (not App/Config).

Hope this help you.

Theme © iAndrew 2016 - Forum software by © MyBB