yii2-advanced-app

Installation Yii2 Advanced template not working

笑着哭i 提交于 2019-12-08 10:40:28
问题 When I try to deploy the Yii2 advanced template, I always end up with a not working application. The error message is: Invalid Parameter – yii\base\InvalidParamException The file or directory to be published does not exist: [...]/yii-application/ vendor/bower/jquery/dist I tried to install via the recent composer version, with and without the the fxp asset plugin. The error message is same for both. I used the official documentaion for the installation on my Ubuntu64 16.04 webserver. 回答1:

Using the 2 amigos file uploader in yii2

走远了吗. 提交于 2019-12-08 04:25:59
问题 Am implementing the 2amigos file uploader it only displays the interface but does not show or upload any file I have tried this: <?= FileUploadUI::widget([ 'model' => $evidence, 'attribute' => 'path', 'url' => ['media/upload', 'id' => $evidence], 'gallery' => false, 'fieldOptions' => [ 'accept' => 'image/*' ], 'clientOptions' => [ 'maxFileSize' => 2000000 ], // ... 'clientEvents' => [ 'fileuploaddone' => 'function(e, data) { console.log(e); console.log(data); }', 'fileuploadfail' => 'function

Yii2 - How can I remove unnecessary information from log file?

一个人想着一个人 提交于 2019-12-08 03:13:39
问题 I am trying to log messages in Yii2 which are then emailed to my specified email address. config file web.php contains: 'mail' => [ 'class' => 'yii\log\EmailTarget', 'categories' => ['mail'], 'logVars' => [], 'mailer' => 'mailer', 'message' => [ 'from' => ['user@example.com'], 'to' => ['user1@example.com'], 'subject' => 'Log message', ], ], I am logging message like this: Yii::info('Log message example','mail'); After successful execution, I am receiving mail like this: 2018-07-31 09:01:12

In Yii2 framework, better place to define common function which is accessible everywhere like controller, model, view

牧云@^-^@ 提交于 2019-12-08 02:59:38
Like i want to create function with name "dt()" function dt(){ return date('Y-m-d H:i:s'); } and want to access it like this:- echo dt(); //retrun current date and time format Which is better place in Yii2 framework to do that? You can use it this way: http://www.yiiframework.com/extension/yii2-helpers/ Create a folder /common/helpers/ , then create a helper class there and add your static methods. namespace common\helpers; class DateHelper { public static function dt(){ return date('Y-m-d H:i:s'); } } Usage use common\helpers\DateHelper; echo DateHelper::dt(); For yii2, First Make a folder

Yii2 best practices translating dynamic content

北战南征 提交于 2019-12-07 16:48:53
问题 Can anyone share own experience and best practices implementing multilingual sites with Yii2? I want translate user input that is stored in database. For example article, that may have its name in three different languages, body and some translatable attributes as well. Does Yii2 have built in features to translate the dynamic content? Or should I use third party extensions like these ones below: https://github.com/creocoder/yii2-translateable https://github.com/LAV45/yii2-translated-behavior

From Backend to Frontend Yii2 Advanced App

时光怂恿深爱的人放手 提交于 2019-12-07 15:24:35
问题 I'm trying to link some controllers from frontend to backend. After some hours I don't where could be the problem. Backend file: main.php 'urlManager' => [ 'enablePrettyUrl' => false, 'showScriptName' => false, 'baseUrl' => '/backend/web', ], 'urlManagerFrontEnd' => [ 'class' => 'yii\web\urlManager', 'baseUrl' => '/frontend/web', 'enablePrettyUrl' => false, 'showScriptName' => false, ] file: SiteController.php public function actionIndex() { // User's variable $user = \common\models\User:

Yii2 REST+ Angular Cross Domain CORS

大兔子大兔子 提交于 2019-12-07 03:43:39
问题 I have developed Angular & Yii2 REST service. Have problem in cross domain. Here below add my angular & Yii2 REST Code. AngularJs : (like 'http://organization1.example.com','http://organization2.example.com',....) $http.defaults.useXDomain = true; $http.defaults.withCredentials = true; $http.defaults.headers.common['Authorization'] = 'Bearer ' + MYTOKEN My Request from Angular Controller: apiURL = 'http://api.example.com'; $http.get(apiURL + '/roles') .success(function (roles) { }) .error

How to upgrade Yii 1.x to Yii 2.0

ぐ巨炮叔叔 提交于 2019-12-06 23:23:59
问题 How to upgrade Yii 1.x version to Yii 2.0 latest release version? I am using ubuntu OS , Process to updating my old Yii to new Yii release version 2.0? 回答1: The Yii2 guide has excellent documentation in this regard see Upgrade from v1 I recently migrated couple of moderately complex applications from Yii 1.x to Yii 2.0. There are two ways to go about it , either you can run Yii 1.x and Yii 2 at the same time see using-yii-2-with-yii-1. Then migrate part by part, while it is possible it was

How to set multi select value from array object in yii2 while updating

戏子无情 提交于 2019-12-06 14:18:49
I have table which have multiple reference to ohter tables like user id name email categories id title user_categories user_id category_id Here a user will have multiple category associated with him/her I am able to save these successfully with new records like following View File: echo $form->field($package_categories, 'category_id')->dropDownList( ArrayHelper::map( StudyMaterialCategories::find()->all(), 'id', 'title'), ['multiple' => true] ); Save New record: $model = new Packages(); $package_categories = new PackageCategories(); $request = Yii::$app->request; if ($request->isPost) {

Yii2 REST API BasicAuth not working

只愿长相守 提交于 2019-12-06 13:51:45
问题 Im implementing REST API Authentication module as following step 1. Create user by Admin 2. First tim: login by Basic Auth to return access_token 3. Use access_token at step 2 to Auth user by. QueryParamAuth as this instruction it work with QueryParamAuth https://github.com/yiisoft/yii2/blob/master/docs/guide/rest-authentication.md But it not work at step2. Auth by BasicAuth I debug it. $this->auth always return null. Although $username and $password right class HttpBasicAuth extends