yii2

Yii2 Rest Api User bearer Authentication expiration time

倾然丶 夕夏残阳落幕 提交于 2019-12-11 02:18:44
问题 i am currently working on a yii2 based Rest api. i use bearer token for user authentication.let me explain the requirement. 1)first user authenticated from a external php application using their credentials. 2)he/she got an access Token. 3)each subsequent request is made using this access token. public static function findIdentityByAccessToken($token, $type = null) { return static::findOne(['auth_key' => $token]); } this is where i start thinking. i do not found any expiration time for the

Yii2 - Bad Request (#400) | Frontend and backend cookies

折月煮酒 提交于 2019-12-11 02:13:56
问题 The issue appears only when I open frontend and backend in the same browser . Scenario: Interact with Backend -> Switched Tab -> Interact with Frontend -> Switched Tab Back -> Interact with Backend -> Bad Request (#400) Cookie Backend 'identityCookie' => [ 'name' => '_backendIdentity', 'path'=>'/admin', 'httpOnly' => true, ], Cookie Frontend 'identityCookie' => [ 'name' => '_frontendIdentity', 'path'=>'/', 'httpOnly' => true, ], Session Backend 'session' => [ 'name' => 'session_backend' ],

Yii2 whenClient validation issue

冷暖自知 提交于 2019-12-11 02:13:54
问题 For some reason I cannot get conditional rule 'required' to work. Even if I reduce the condition to "always return false", required-validation seems to check this unnecessary field: public function rules() { return [ [['order_id', 'product_id', 'quantity'], 'required'], ['product_date', 'required', 'whenClient' => "function(attribute, value) { return false; }" ], // more rules here [['date_create', 'date_update', 'product_date'], 'safe'], // more rules here ]; } On form submit save() fails

Store $_POST in Yii2 session

断了今生、忘了曾经 提交于 2019-12-11 02:11:49
问题 I'm having a little trouble with my quiz form. I'm using a page to show a single question that a user answers, from there I was hoping to save the question id and option id (My form is multiple choice, i set the options). My HTML looks like this: <input type="radio" name="question[3]" value="4">My Answer When the form is posted I am doing this if(isset(Yii::$app->session['question'])){ // Get posted array $question = $_POST['question']; Yii::$app->session['question'] = $question; print_r(Yii:

image are save in folder but not saved in database in yii2.0

不打扰是莪最后的温柔 提交于 2019-12-11 01:33:09
问题 i am new in yii and i use to upload images in databse but images are stored in folder but not saved in database what is the problem with this code coud not undurstand public function actionCreate() { $model = new Jobs; // $site_url=Yii::$app->getUrlManager()->createAbsoluteUrl(''); if ($model->load(Yii::$app->request->post()) && $model->save()) { $image = UploadedFile::getInstance($model,'image'); $imagepath='upload/jobs/'; $path=$imagepath.rand(10,100).$image->name; if(!empty($image)){

yii2 grid filtering is not working

故事扮演 提交于 2019-12-11 01:22:56
问题 my grid view filter is not filtering categories, I have given category_id to nesserray places but yet it is not filtering my posts according to their category_id, please help me. here are my source codes: post-->index.php <?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'title', [ 'attribute'=>'category_id', 'value'=>function($model) { return $model->category->name; }, 'filter'=>$category ], [

TinyMCE multiple editors not rendering correctly in Yii2

牧云@^-^@ 提交于 2019-12-11 01:19:25
问题 I'm using Yii2 and the widget from 2amigos/yii2-tinymce-widget. The editor only looks correct when I'm using it just once, but when I'm using multiple editors the second, third, etc. editors are not rendering correctly. Do I have to stop the initialization of the TinyMCE after the first one? Here is an example of the missed rendering: And here is the code where I'm using the widget: <?php $form = ActiveForm::begin([ 'id' => $ansichtAktiv->id, 'enableClientValidation' => true, 'action' =>

Yii2- How to search gridview records using kartik date time picker

纵饮孤独 提交于 2019-12-11 01:17:39
问题 I am working in yii2 framework. I have two kartik date time pickers in my index view. I want to use them to search the records. <section class="content"> <div class="box"> <div class="box-body"> <p> <?= Html::a('Update Record', ['create'], ['class' => 'btn btn-success']) ?> </p> <div class="div1" style="float: left; text-align: right; width: 25%;"> <span style="padding-bottom: 10px; border-bottom: 1px solid black"> <?php echo DateTimePicker::widget([ 'name' => 'startTime', 'options' => [

How to host ASP.NET Core web-app inside an Apache website?

假装没事ソ 提交于 2019-12-11 01:13:52
问题 I have an old php application developed using the Yii2 framework hosted on a Centos server at the path /var/www/html . This application is accessible at http://somedomain.com/ . I am working on new API project developed using ASP.NET MVC Core which needs to be accessible at http://somedomain.com/v2/ . So, is it possible to host the dotnet core application inside an Apache site and have both of them work at the same time? If yes, how can I accomplish it? 回答1: You could add a reverse proxy to

appendTimestamp and registerAssetBundle

一曲冷凌霜 提交于 2019-12-11 01:12:34
问题 I am using the following configurations to add the timestamp in the assets path via asset manager. 'assetManager' => [ 'appendTimestamp' => true, appAsset.php class AppAsset extends AssetBundle { public $basePath = '@webroot'; public $baseUrl = '@web'; public $css = [ '/css/style.css' ]; } In view AppAsset::register($this); But in html I still see '/css/style.css' without timestamp. I saw solution https://github.com/yiisoft/yii2/issues/9101#issuecomment-267274327 $file = '/css/style.css';