Extending YII2 package that is loaded into vendor path

I need to make some changes to faker to create fake data specific to my app. I also added additional names to the persons provider.

I want to extend faker so that my changes are outside of the vendor path so updates will not overwrite my changes.

I am not sure where to put these files in my app, and how to tie it into faker…

This code will be an ongoing part of my app.

-John

Just extend it, then! :)

Since it is a controller, add a controller that extends from it and update the config:




	'controllerMap' => [

    	'fixture' => [

        	'class' => 'app\controllers\FixtureController',

    	],

	],



Or, you could create a module to make it cleaner.

Thanks jacmoe,

So I create a controller, copy the existing code and update it.

Then update the map to point to the new controller so the old controller does not get called?

Is that basically whats happening? I am still trying to wrap my assembly language brain around many of these concepts…

-John

What is happening is that you are mapping ‘\Yii::$app->fixture’ to your own class.

Alternatively, you can do a lot without having to extend the global fixture class/component.

See this: http://www.yiiframew…t-fixtures.html

Perhaps, you can create a couple of custom fixtures that you can set, without going the route of creating a full-blown overridden copy. :)

Edit:

Meaning that you can override locally instead of globally.

The doc header in https://github.com/y...eController.php might give you some ideas.

Yes, that is what’s happening. :)