[ReflectionException] Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist

Published on

Composer throws [ReflectionException] Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist php composer.phar update It gives me this error: [ReflectionException] Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist [ErrorException] Declaration of Fxp\Composer\AssetPlugin\Repository\AbstractAssetsRepository::whatProvides() should be compatible with Composer\Repository\ComposerRepository::whatProvides(Composer\DependencyResolver\Pool $pool, $name, $bypassFilters = false) Can someone help me how to fix this? Solution:  About nine days ago, Composer\Repository\ComposerRepository::whatProvides api changed. (#2668) So, if … Continue reading [ReflectionException] Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist

How to get response as json in yii2?

Published on

How to get response as json  in yii2? Create this function in your (base) Controller: /** * Return data to browser as JSON and end application. * @param array $data */ protected function renderJSON($data) { header(‘Content-type: application/json’); echo CJSON::encode($data); foreach (Yii::app()->log->routes as $route) { if($route instanceof CWebLogRoute) { $route->enabled = false; // disable any weblogroutes … Continue reading How to get response as json in yii2?

How to set timezone in yii2

Published on

Set proper format of timstamp into local time in GridView of yii. When someone is reffering to application property or application config it means “root” config variable, in this case timeZone. Config part: <?php // in protected/config/main.php return array( ‘timeZone’ => ‘Asia/Calcutta’ // Other configuration…. ); Hope it will help you. How to set a … Continue reading How to set timezone in yii2

How to add textarea in yii2

Published on

You can use Active Forms to create fields like textarea for example <?php $form = ActiveForm::begin([‘id’ => ‘downloadSourceCode’]); ?> <?= $form->field($model, ‘description’)->textArea([‘rows’ => ‘6’]) ?> <?= Html::submitButton(‘Submit’) ?> <?php ActiveForm::end(); ?> In the previouse example you are creating a form with a textarea inside, you can give it a name and pass the model from … Continue reading How to add textarea in yii2

How to use JEASYUI for yii2 by installing yii2-jeasyui

Published on

Implement jQuery EasyUI GPL Edition on Yii2. INSTALLATION The preferred way to install this extension is through composer. Either run php composer.phar require sheillendra/yii2-jeasyui “dev-master” or add “sheillendra/yii2-jeasyui”: “dev-master” to the require section of your composer.json file. USAGE in config.php change view components like this : ‘components’ =>[ #… other ‘view’ => [ ‘theme’ => … Continue reading How to use JEASYUI for yii2 by installing yii2-jeasyui

How can push an array or object to mongodb with yii

Published on

The solution long time ago and i thought i should share it here. So i am pushing the 1st object in mileage node like that: $model = Customer::findOne($customerId); if ($model->load(Yii::$app->request->post())) { $mileage = new mileage(2, ‘British Airways’, ‘Usman’, 10000); $model->mileage = array($mileage); $model->save(); return $this->redirect([‘view’, ‘id’ => (string) $model->_id]); } So to add another object … Continue reading How can push an array or object to mongodb with yii

How can I rewrite urls in Yii2

Published on

Need to add following rules code for urlManager in config/main.php(if advance template) or web.php. [ ‘components’ => [ ‘urlManager’ => [ ‘showScriptName’ => false, ‘enablePrettyUrl’ => true, ‘enableStrictParsing’ => false, ‘rules’ => [ ‘post/<id:\d+>-example’ => ‘post/index’, ], ], ], ]