yii2-advanced-app

yii2 gii CRUD Generator error - Class 'Message' does not exist or has syntax error

主宰稳场 提交于 2020-01-06 19:36:11
问题 I'm creating a basic text only private messaging system for a website using yii2 advanced. I'm using the gii model and CRUD generators but have encountered a problem with the CRUD generation after I have created the model class. I'm wondering whether it might be an issue with the foreign keys on the message table which have a one to many relationship with the users table (i.e. one user can have many messages). When I attempt to run the CRUD generator with- Model Class- Message Search Model

Get facebook friend list in yii2 framework

坚强是说给别人听的谎言 提交于 2020-01-06 19:23:13
问题 I am using Yii2 Framework and I have to get Facebook friend list in web-service, for this i am following this steps: FB FriendList Tried this: <?php use yii\Facebook\Facebook; // facebook class public function getFbUserListFB() { $fb = new Facebook([ 'app_id' => 'appID', 'app_secret' => 'appSECRET', 'default_graph_version' => 'v2.3' ]); $response = $fb->get('/me'); print_r($response); } ?> but getting this error: { "name": "PHP Fatal Error", "message": "Class 'yii\Facebook\Facebook' not found

Yii2 how to save received JSON data into database

风流意气都作罢 提交于 2020-01-06 06:48:04
问题 I have created an API which returns me an array of data in json Array ( [0] => stdClass Object ( [MSN] => 002999001207 [PingDateTime] => 2018-05-04T16:33:27 [PingValue] => 22 ) [1] => stdClass Object ( [MSN] => 002999001195 [PingDateTime] => 2018-05-04T16:34:11 [PingValue] => 21 ) [2] => stdClass Object ( [MSN] => 002999001180 [PingDateTime] => 2018-05-04T14:42:40 [PingValue] => 20 ) [3] => stdClass Object ( [MSN] => 002999001157 [PingDateTime] => 2018-05-04T14:42:52 [PingValue] => 30 ) [4] =

Yii2 how to save received JSON data into database

ⅰ亾dé卋堺 提交于 2020-01-06 06:48:00
问题 I have created an API which returns me an array of data in json Array ( [0] => stdClass Object ( [MSN] => 002999001207 [PingDateTime] => 2018-05-04T16:33:27 [PingValue] => 22 ) [1] => stdClass Object ( [MSN] => 002999001195 [PingDateTime] => 2018-05-04T16:34:11 [PingValue] => 21 ) [2] => stdClass Object ( [MSN] => 002999001180 [PingDateTime] => 2018-05-04T14:42:40 [PingValue] => 20 ) [3] => stdClass Object ( [MSN] => 002999001157 [PingDateTime] => 2018-05-04T14:42:52 [PingValue] => 30 ) [4] =

How i can force an yii2 module to use a specific connection for all his models?

这一生的挚爱 提交于 2020-01-05 07:04:15
问题 on a module I have add a component named db where i put, like the main Yii component, the data for database connection, I need in my module use everytime the db specified in his configuration for all models and not the main database connection, how I can do this? 回答1: You have several way eg. using a separated configuration in app/config/main.php eg adding a specific dbMyMod to component config return [ // ... 'components' => [ // ... 'db' => [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql

Yii2 How to access a folder in “root” folder?

六月ゝ 毕业季﹏ 提交于 2020-01-05 05:47:05
问题 I have made a website with Yii2 advanced template and I want to access files in the upload folder located in the "root" folder. I have : backend/web/ frontend/web/ uploads/ I have followed the 1st answer of Yii2. Access to higher level folder So my .htaccess is Options +FollowSymlinks RewriteEngine On # deal with backend first RewriteCond %{REQUEST_URI} /(backend) RewriteRule ^backend/assets/(.*)$ backend/web/assets/$1 [L] RewriteRule ^backend/css/(.*)$ backend/web/css/$1 [L] RewriteRule

Yii2 Saving tabular data using yii2-formwizard

ぐ巨炮叔叔 提交于 2020-01-05 05:36:06
问题 I am integrating yii2-formwizard for tabular input but unable to submit the data to my controller action and use Model::loadMultiple . I have to declare my model as array and then I need to initialize it before passing to view and in buttflattery/yii2-formwizard front-end I must specify my model as array fine but I can not retrieve data from my controller dynamically. I need to dynamically create instance from front-end and save them in back end. I can save only the instance I have initialize

Yii2 get post request value not working

左心房为你撑大大i 提交于 2020-01-05 04:43:10
问题 Why Yii::$app->request->post() not working? Form: <?php $form = ActiveForm::begin(); ?> <?= $form->field($model, 'parent') ->dropDownList($model->AuthItemDropdown ); ?> <?= $form->field($model, 'child[]') ->dropDownList($model->AuthItemDropdown, ['multiple'=>'multiple'] ); ?> Controller: public function actionCreate(){ $model = new AuthItemChild(); if ($model->load(Yii::$app->request->post())){ $parent = Yii::$app->request->post('parent'); echo $parent; // show nothing $x = Yii::$app->request

Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www)

别说谁变了你拦得住时间么 提交于 2020-01-05 04:28:09
问题 I have a custom members system that I have made: Yii2 Members System. You can refer to that for full details, or install it so you can work with it for this question. I have frontend and backend just as Yii2 provides, with a few modifications to separate the sessions/cookies so that backend works with the Admin model and pulls from an admin table. Similar to old traditional member systems. mainsite is basically a clone of frontend and it's role is to be the main website. What you get when you

Where do I put global Variables in Yii2 similar to YII_DEBUG and YII_ENV

自作多情 提交于 2020-01-03 16:47:42
问题 I'm building a website that has a "subdomain" called marketplace. so the url will be marketplace.sample.com. I'm using the Yii2 advanced application and I added the following code to my index.php located in frontend/web. defined('MARKETPLACE') or define('MARKETPLACE', preg_match('/^marketplace/', $_SERVER['HTTP_HOST']) === 1 ? true : false); This works on my environment, however, I just realized that the index.php file is in the .gitignore file in Yii2 because that file is created by the init