Questions tagged [yii2]

Yii 2 is the latest version of the Yii framework - a high-performance, component-based PHP framework

Yii Framework

Yii is a generic Web programming framework, meaning that it can be used for developing all kinds of Web applications using PHP. Because of its component-based architecture and sophisticated caching support, it is especially suitable for developing large-scale applications such as portals, forums, content management systems (CMS), e-commerce projects, RESTful Web services, and so on.

Yii 2.0 is the current version of the Yii PHP framework, released on October 12, 2014. The latest version can be downloaded from the Yii website. Guidelines on how to upgrade minor Yii 2.0 version and changelog can be found here.

Yii 2.0 is a complete rewrite of Yii 1.1 based on PHP 5.4 improvements and aims for simplicity, performance and extensibility. The framework adopts namespaces and traits, PSR standards, , and . Yii 2.0 implements the dependency injection container and service locator. It makes the applications built with Yii more customizable and testable.

Official documentation can be found in the Definitive Guide to Yii 2.0. Further important documentation sources:

More information on the current project status can be found in the Yii 2.0 release announcement and the project roadmap.

14789 questions
43
votes
1 answer

Performing raw SQL queries in Yii2?

I have written the below queries as I migrate my PHP website to the Yii2 framework. I want to add them to my controller so as to display the top 10 bets won. I have tried going through many Yii2 database classes but I cannot get it to work. My…
Lenny Carmi
  • 663
  • 1
  • 6
  • 12
43
votes
4 answers

Disable CSRF validation for individual actions in Yii2

Is there a way to disable CSRF validation for some actions of the controller keeping it enabled for the other ones? In my case I have several configurable Action classes, that are intended to be injected into controllers. I can't pass csrf…
coderlex
  • 542
  • 1
  • 4
  • 9
41
votes
8 answers

how to use not null condition in YII2

Hi i want to use not null condition in my yii2 query how should i use that. i don't want city and state null. My query is $query = new Query; $query->select('ID, City,State,StudentName') …
Vikram Pote
  • 4,959
  • 4
  • 31
  • 34
40
votes
10 answers

yii2 hidden input value

In Yii2 I'm trying to construct hidden input echo $form->field($model, 'hidden1')->hiddenInput()->label(false); But I also need it to have some value option, how can I do that ?
David
  • 3,756
  • 12
  • 45
  • 77
40
votes
11 answers

Why get Unable to verify your data submission error in Yii2?

Error: Unable to verify your data submission error Create one public function in Yii2. But, submit data not accept in this method, see following error images. Why is this happen?
Bharat Chauhan
  • 2,802
  • 4
  • 29
  • 45
40
votes
6 answers

How to use the swiftMailer in Yii2

I can't finally understand how to use the swiftMailer extension in Yii2. Judging by that on this subject I didn't find questions, the task is trivial, but up to the end I couldn't understand. There are examples which don't describe in more detail…
frops
  • 1,924
  • 4
  • 26
  • 39
39
votes
10 answers

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated

when i got upgraded my ubuntu from 15.10 to 16.04 i have this erro in my yii2 project SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column…
Saltern
  • 995
  • 2
  • 12
  • 38
39
votes
6 answers

Install package on non-empty folder using composer

I tried to install package via composer but it's keep telling me that this directory is not empty so how can I install package on non-empty folder using composer ? is there force install command ? error message: [InvalidArgumentException] …
Abudayah
  • 3,599
  • 6
  • 37
  • 56
38
votes
10 answers

Getting base URL in Yii 2

I am trying to get the base URL for the project in Yii 2 but it doesn't seem to work. According to this page you used to be able to do: Yii::app()->getBaseUrl(true); In Yii 1, but it seems that that method in Yii 2 no longer accepts a…
Brett
  • 16,869
  • 50
  • 138
  • 258
38
votes
1 answer

How do I work with many-to-many relations in Yii2

For example in one-to-many due to documentation (http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#relational-data) you can link two models in this way (one-many = company-zone): $defaultZone = new Zone; $defaultZone->name =…
raiym
  • 1,296
  • 1
  • 20
  • 48
37
votes
1 answer

Yii2 : ActiveQuery Example and what is the reason to generate ActiveQuery class separately in Gii?

Could you provide an example usage. Description will be highly appreciated. I can not find a good example for it.
akmnahid
  • 736
  • 2
  • 6
  • 18
36
votes
1 answer

ActiveRecord batch insert (yii2)

Is it possible to insert multiple rows in one query with Yii's ActiveRecord? Or is this only possible via the lower-level DAO objects? I have two models 1- Transaction 2-TransactionItems There are multiple rows(onclick add row) in transaction…
user1561346
  • 672
  • 3
  • 12
  • 26
36
votes
3 answers

Yii2 disable Bootstrap Js, JQuery and CSS

Same as title, i don't want using bootstrap.css and bootstrap.js. I try using: 'assetManager' => [ 'bundles' => [ 'yii\bootstrap\BootstrapAsset' => [ 'css' => [], ], ], ], It remove bootstrap.css but can't remove…
taratula
  • 457
  • 1
  • 4
  • 10
36
votes
9 answers

How to set the default controller in yii2

I have UserControler and I run it in virtual server http://basic.com/index.php?r=user/index. How can I set up UserController and action index to be the default when I go to http://basic.com
Jackson Tong
  • 646
  • 1
  • 6
  • 17
35
votes
3 answers

How to use events in yii2?

I've been through the documentation and all the articles on Yii2 events found using Google. Can someone provide me a good example of how events can be used in Yii2 and where it may seem logical?
nirajan poudel
  • 632
  • 1
  • 8
  • 13