extending CDataProvider

I need to extend CDataProvider class with a new custom dataprovider.

In which directory is better to put the new class?

Assuming it’s just for one project, protected/components is generally a good place.

I created it under protected/components of the admin module as you sugggest.

Should i declare it somewhere (maybe main.php) before being able to use it?

If you have put inside the components directory.

You can call it any where like

//if myDataProvider extends CDataProvider

$dataProvider=new myDataProvider;

You can call also put inside main.php with some predefined properties.