yii2

How to fix “FFmpeg command cannot work when multiple mp3 file to process into one” on server side

安稳与你 提交于 2019-12-08 13:35:02
问题 I am using FFmpeg in my php yii2 project. FFmpeg working fine in my project but one major problem is execute FFmpeg command with multiple input file. When i try to use single file to process in ffmpeg command then it works. so, how can i fix this problem? I am using hostGator shared plan for my project. Please, help if is there any process limit or file open limit on server that i don't know. I have tried using this command in php exec(): ffmpeg -y -i /uploads/ac/10122018-09351115

YII2: How can I create a link/url in a Menu item to point to an external webpage instead of an action or view of my application

耗尽温柔 提交于 2019-12-08 13:03:33
I am using the YII2 Menu Widget and did not find the solution to add attribute options like class , target on created link. My code is below: echo Menu::widget( [ 'options' => [ 'class' => 'sidebar-menu' ], 'items' => [ [ 'label' => Yii::t('backend', 'Admin'), 'url' => Yii::$app->homeUrl, 'icon' => 'fa-list-alt', 'options' => [ 'class' => 'treeview', ], 'items' => [ [ 'label' => Yii::t('backend', 'External link'), 'url' => 'http://google.com', 'icon' => 'fa-list-alt', 'options' => [ 'target' => '_blank', ], ], ] ], ] ] ); Option target is not added on generated link. add the target like below

Yii2 login give access to backend when user login is from frontend

跟風遠走 提交于 2019-12-08 12:24:10
问题 In yii2 advance template. If i am doing following i get the access of back-end without login, even if there are two different databases configuration for front-end and back-end Login from front-end login page. After successful login to front-end. When i open a back-end link, it is showing already logged in. No login is required by back-end. Visa - versa if i do the opposite. How to restrict this? 回答1: You have to set different cookies for frontend and backend in config/main.php file. For Eg.:

Change language in Yii2

久未见 提交于 2019-12-08 12:22:27
问题 I want to change language using dropdown for English and Norwegian. Code is working fine but issue is it is working for only one time, whenever I refresh page language is change to English. view page. <select class="form-control user_language"> <option value="en">English</option> <option value="nl">Norwegian</option> </select> JS Code. <script> $(".user_language").change(function(){ language=this.value; $.ajax({ url:'<?=Yii::$app->request->baseUrl?>/site/changelanguage', type:"GET", data:

How do I get rid of composer-asset-plugin in yii2

旧街凉风 提交于 2019-12-08 12:17:44
问题 Since the fxp\composer-asset-plugin broke last year, I am continuously experiencing problems installing yii2. whenever I run a composer update command it fails due to this composer asset plugin. Everyday a new error pops up. I have read number of articles, github issues, with Sam and Alexander (maintainers of Yii Framework) continuously replying to the same problem then would close the topic. none of the updates to this plugin seem to be a fool-proof solution. Now instead of asking how to

ajax request from a js file to yii2 controller function

泄露秘密 提交于 2019-12-08 11:56:39
问题 function facebookAuth() { $.ajax({ url: 'index.php?r=account/fbauthorize', type: 'GET' }); } it is a simple function i wrote just to invoke the function in the controller, the GET type works fine, but the POST does not. give me this error "Bad Request (#400): Unable to verify your data submission." it is something to do with CSRF validation in yii2, but i can't solve it. 回答1: There are two important steps: 1) Register your js file as follows: $this->registerJsFile(Yii::$app->homeUrl . 'js

Yii2 hasMany/via vs. hasMany/viaTable vs. find/joinWith

孤者浪人 提交于 2019-12-08 10:50:29
问题 I have a many to many relation in Yii2: RecipeUnit - IngredientWeight - Ingredient. In model RecipeUnit: public function getIngredientWeights() { return $this->hasMany(IngredientWeight::className(), ['recipe_unit_id' => 'id']); } public function getIngredients() { return $this->hasMany(Ingredient::className(), ['id' => 'ingredient_id']) ->via('ingredientWeights'); } Using the following code ActiveQuery generates two SQLs instead of one join, and it takes long time ( $model is a RecipeUnit

How to retrieve the session values in Yii 2

拥有回忆 提交于 2019-12-08 10:42:47
问题 I am facing the problem with Yii 2 session when I add the products to the cart session and fetch session cart values. session_start(); print_r($_SESSION); exit; I got this line. Array ( [__flash] => Array ( ) [__id] => 65 ) Also while trying Yii 2 way: $session = Yii::$app->session; print_r($session); exit; I am getting this value: yii\web\Session Object ( [flashParam] => __flash [handler] => [_cookieParams:yii\web\Session:private] => Array ( [httponly] => 1 ) [_hasSessionId:yii\web\Session

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:

Yii2-user: How to create admin user in batch mode?

寵の児 提交于 2019-12-08 10:31:45
问题 When deploying my application there is of course always an admin user. How can I create such an admin user as a first user without any interaction ... ... by means of SQL? ... using a Yii2-migration? 回答1: Found it. There is an easy way to do this with Yii2 builtin migrations. In Yii2-user there are some hooks we can use to create users. This code has to be inserted in a migration. after creating a new migration ./yii migrate/create , preferably after creating initial tables in the database: