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.

15456 questions
108
votes
10 answers

Yii2 data provider default sorting

In Yii 1.1 this code works for default sorting: $dataProvider = new CActiveDataProvider('article',array( 'sort'=>array( 'defaultOrder'=>'id DESC', ), )); How default sorting can be set in Yii2? Tried below code, but no…
Sarvar Nishonboyev
  • 12,262
  • 10
  • 69
  • 70
86
votes
13 answers

How to make a drop down list in yii2?

How to make a dropdown in yii2 using an activeform and a model? Since all the methods has changed in yii2,how it is done in the new one?
Dency G B
  • 8,096
  • 9
  • 47
  • 78
80
votes
7 answers

Composer throws [ReflectionException] Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not exist

I installed the latest version (1.0.0. stable) of composer and in my Yii2 project I typed this: php composer.phar update It gives me this error: [ReflectionException] Class Fxp\Composer\AssetPlugin\Repository\NpmRepository does not…
Marko Mikulić
  • 1,047
  • 2
  • 10
  • 15
66
votes
14 answers

Enable clean URL in Yii2

How can I enable clean urls in Yii2. I want to remove index.php and '?' from url parameters. Which section needs to be edited in Yii2 for that?
user7282
  • 5,106
  • 9
  • 41
  • 72
65
votes
4 answers

Multiple database connections and Yii 2.0

I have two databases, and every database has the same table with the same fields, but how do I get all records from all of two databases at the same time in Yii 2.0?
Chhorn Soro
  • 3,061
  • 8
  • 27
  • 43
59
votes
13 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
  • 1,305
  • 2
  • 16
  • 42
59
votes
9 answers

Cannot update yii2 via composer bower-asset/jquery could not be found

I was updating my yii2 via composer then reverted back to the old beta version. Here is the error on my composer: Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be…
Jefren Inocando
  • 1,646
  • 2
  • 12
  • 13
56
votes
8 answers

Yii2 How to perform where AND or OR condition grouping?

I am new to Yii-2 framework. How can i achieve following query in Yii-2 framework using activeQuery and models. SELECT * FROM users AS u WHERE u.user_id IN(1,5,8) AND (u.status = 1 OR u.verified = 1) OR (u.social_account = 1 AND u.enable_social =…
Vikas Chaudhary
  • 728
  • 1
  • 5
  • 12
55
votes
9 answers

How to use not equal to inside a Yii2 query

I want to use a yii2 query in which I want to check a not equal to condition. I tried like this but it didn't give the desired results. How do I do it? $details = MovieShows::find() ->where(['movie_id'=>$id]) …
Bloodhound
  • 2,906
  • 11
  • 37
  • 71
54
votes
6 answers

How to pass param from controller to layout in YII2

I want to send a parameter from controller to layout (i.e. main.php). But I am not able to get the param in main.php I tried: Controller Code: $this->render('index',array('param' => $paramValue)); And this is how i was trying to get this in…
Amit Kumar
  • 3,384
  • 6
  • 25
  • 42
53
votes
2 answers

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
  • 763
  • 1
  • 6
  • 12
53
votes
7 answers

Log the actual SQL query using ActiveRecord with Yii2?

I'm doing this: $students = Student::find()->all(); return $this->render('process', array('students' => $students)); and then this in the view: foreach($students as $student) { echo $student->name . ',  '; echo…
diabetesjones
  • 838
  • 1
  • 7
  • 17
52
votes
4 answers

Yii2 redirect to previous page

Now My application is using gridview to list all information and it's also have pagination.when the user click on pagination number and then click on edit and then save. It redirect user to view page. What I want to do it to redirect user to…
Chhorn Soro
  • 3,061
  • 8
  • 27
  • 43
52
votes
7 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,816
  • 7
  • 40
  • 60
51
votes
2 answers

How can I use a simple Dropdown list in the search box of GridView::widget, Yii2?

I am trying to make a dropdown list in the search box of a GridView::widget, Yii2 for searching related data. So, how can I create a simple dropdown list in the search box of GridView::widget, Yii2 framework? Thanks.
washiur17
  • 617
  • 1
  • 6
  • 12
1
2 3
99 100