I am new to yii and i have to create a yii component for Enom api .I have followed this url Enom application for refrence . It is in core php and i want to implement this in yii as component or module .I have done in this way
put the files interface and class in the yii component folder.
modify the class as mentioned here yii custom component . Now my class name is
EnomServiceand interface name isEnomInterfacei have added these lines also in my classuse Yii; use yii\base\Component; use yii\base\InvalidConfigException;
modified the
main.phpfile in config folder:'import'=>array( 'application.models.*', 'application.components.*', ), 'defaultController'=>'post', // application components 'components'=>array( 'user'=>array( // enable cookie-based authentication 'allowAutoLogin'=>true, ), 'mycomponent' => [ 'class' => 'app\components\EnomService', ],calling in the controller in this way .
public function actionEnom () { echo "asdgsgsag"; $enom = new EnomService('manoj_rudra', 'manoj@41@', false, true); $enom->debug = true; $result= Yii::$app->EnomService->checkDomain('systurn', 'com', true); //$result = $enom->checkDomain('systurn', 'com', true); // This enables domain spinner echo '<pre>'; var_dump($result); echo '</pre>'; }
But it is not working . I am not so much familiar with yii custom component . Please help me to create this .
Are you using Yii or Yii2?
If it is Yii, then you could use plenty of other existing extensions to inspire yourself, for example this one: https://github.com/HeavyDots/yii-sms
As for Yii2 you could do something similar, look into already existing extensions for Yii2 on YiiFramework website and you can see how component classes are defined.
I would recommend:
1) Create a new directory inside "components" named "enom"
2) Place inside that directory all your enom files from https://github.com/comdexxsolutionsllc/MoondayFramework/tree/master/engine/enom
3) Create the component class called "Enom.php" inside the directory, something like this:
4) Then in the configuration properly define the component
5) And finally use it like this
As I said before, haven't used Yii2 yet so this might need tweaking but could point you on the right path.