yii2-advanced-app

Using Yii1 and Yii2 in the same project

夙愿已清 提交于 2019-12-03 13:49:09
I had a project in Yii1.x and now I am using Yii2 for the same projects Project hierarchy is something like this Project1(yii1)/all yii files + project2(yii2) project2(yii2)/frontend + /common + /backend Now I want to know if is it possible to use project2/common/models in project1/protected/controllers How can I achieve this task? Thank you I wouldn't recommend doing it, instead it's better to completely rewrite old application in Yii2. But in case of partial migrating, please read this paragraph in Special Topics Section in Official Guide. Here are some important code snippets from there: 1)

Yii2 View DateTime Format (d-m-Y H:i:s) But When Save/update in DB Change format to Y-m-d H:i:s

非 Y 不嫁゛ 提交于 2019-12-03 12:52:55
问题 I'm Using Kartik DateTimePicker Extension <?= $form->field($model, 'Created')->widget(DateTimePicker::classname(),[ 'model' => $model, 'attribute' => 'Created', 'name' => 'Created', 'options' => ['placeholder' => 'Select Created'], 'pluginOptions' => [ 'format' => 'dd-mm-yyyy hh:ii:ss', 'todayHighlight' => true ] ]) ?> User fill the Create Date the format is d-m-Y H:i:s (like 24-09-2015 11:21:10) But when record save to database then Create Date Format change to Y-m-d H:i:s (like 2015-09-24

Yii 2 RESTful API authenticate with HTTP Basic (Yii 2 advanced template)

我们两清 提交于 2019-12-03 06:02:45
问题 REST API is working without authentication methods. Now i wanted to authenticate REST API with HTTP Basic authentication for API requests via mobile application. I tried with yii2 guide, but it didn't work for me. basically mobile user need to be login with username & password, if a username and password are correct, user need to be login and further API request need to be validate with token. when i debug findIdentityByAccessToken() function $token equal to username. Postman extension used

Object configuration must be an array containing a “class” element in yii2 with mongodb

限于喜欢 提交于 2019-12-02 16:18:10
问题 Error > while login or signup using yii2+ mongodb gives an error. MongoDB connection with yii2 is done. please help me to solve this problem. main-local.php return [ 'components' => [ 'mongodb' => [ 'class' => '\yii\mongodb\Connection', 'dsn' => 'mongodb://sameer:27017/demo', ], 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@common/mail', 'useFileTransport' => true, ], ], ]; main.php return [ 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'components' => [ 'cache'

how to keep selected value on Yii2 html::dropddownlist?

泄露秘密 提交于 2019-12-02 14:33:29
i have the following code in my view: <?=Html::dropdownList('region',null, ArrayHelper::map(Ethioregion::find()->all(),'region','region'),[ 'prompt' => 'Select Region..','style'=>'width:200px',]) ?> and submit button <?= Html::submitButton('Search', ['name' => 'dele','class' => 'btn btn-primary']) ?> my code working well but I have one big problem. I select a region and click the search button, the result comes correctly, and 10 result is shown per page when I click the next page, it gives me false data, I notice this is due to the selected value on the dropdownlist is reset. I tried both

Why by every refreshing page, cache reload anew?

懵懂的女人 提交于 2019-12-02 12:37:51
I've programmed my website by Yii2. When I refresh my website it works like Ctl + F5 , and all the font awesome and all the cache of my site reload again. It look likes I open the page first time. Link of my website Nana Partykar Add, this in your config file. According to your need. $linkAssets Whether to use symbolic link to publish asset files. Defaults to false, meaning asset files are copied to $basePath. Using symbolic links has the benefit that the published assets will always be consistent with the source assets and there is no copy operation required. This is especially useful during

Yii2: Separate front and backend in advanced-app doesn't work on XAMPP

╄→гoц情女王★ 提交于 2019-12-02 09:43:59
问题 I simply want to access the backend part via www.domain.com\admin and frontend by www.domain.com . What I did in my root .htaccess is : Options -Indexes # follow symbolic links Options FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_URI} ^/admin/$ RewriteRule ^(admin)/$ /$1 [R=301,L] RewriteCond %{REQUEST_URI} ^/admin RewriteRule ^admin(/.+)?$ /backend/web/$1 [L,PT] RewriteCond %{REQUEST_URI} ^.*$ RewriteRule ^(.*)$ /frontend/web/$1 It redirects to the the frontend but doesn't work

Object configuration must be an array containing a “class” element in yii2 with mongodb

浪子不回头ぞ 提交于 2019-12-02 08:59:26
Error > while login or signup using yii2+ mongodb gives an error. MongoDB connection with yii2 is done. please help me to solve this problem. main-local.php return [ 'components' => [ 'mongodb' => [ 'class' => '\yii\mongodb\Connection', 'dsn' => 'mongodb://sameer:27017/demo', ], 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@common/mail', 'useFileTransport' => true, ], ], ]; main.php return [ 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'components' => [ 'cache' => [ 'class' => 'yii\caching\FileCache', ], 'user' => [ 'identityClass' => 'common\models\User',

Yii2: Separate front and backend in advanced-app doesn't work on XAMPP

我的梦境 提交于 2019-12-02 07:10:29
I simply want to access the backend part via www.domain.com\admin and frontend by www.domain.com . What I did in my root .htaccess is : Options -Indexes # follow symbolic links Options FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_URI} ^/admin/$ RewriteRule ^(admin)/$ /$1 [R=301,L] RewriteCond %{REQUEST_URI} ^/admin RewriteRule ^admin(/.+)?$ /backend/web/$1 [L,PT] RewriteCond %{REQUEST_URI} ^.*$ RewriteRule ^(.*)$ /frontend/web/$1 It redirects to the the frontend but doesn't work properly with the backend. Can't realize what is the problem because I am using the same lines of

Yii2 order items of many-to-many relation

若如初见. 提交于 2019-12-02 04:17:28
问题 I've 2 tables (sliders, images) related with junction (sliders_images) table, the relation work fine but I nedd to get related data with specific order, the attribute that define the right order is in the junction table, the relation is defined as: public function getImages(){ return $this->hasMany(Images::className(), ['id' => 'image_id']) ->viaTable('sliders_images', ['slider_id' => 'id'], function($query){ $query->orderBy('sliders_images.display_order ASC'); }); } when i call $model-