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
103
votes
8 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
  • 8,878
  • 7
  • 55
  • 55
86
votes
12 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
  • 7,856
  • 9
  • 42
  • 74
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,017
  • 1
  • 9
  • 14
64
votes
13 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,146
  • 8
  • 38
  • 67
59
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
  • 2,735
  • 5
  • 22
  • 41
58
votes
8 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,616
  • 2
  • 12
  • 13
52
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,720
  • 8
  • 31
  • 66
51
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…
Maverick
  • 2,523
  • 4
  • 23
  • 39
49
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
  • 798
  • 1
  • 6
  • 17
48
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
  • 593
  • 1
  • 4
  • 10
48
votes
8 answers

URL in Yii2 GridView

I have this code: $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], [ 'label' => 'bla', 'format' => 'url', 'value' =>…
Sarvar Nishonboyev
  • 8,878
  • 7
  • 55
  • 55
47
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
  • 627
  • 1
  • 5
  • 12
47
votes
3 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
  • 2,735
  • 5
  • 22
  • 41
47
votes
5 answers

What's the difference between Yii 2 advanced application and basic?

What is the difference between advanced application and basic application in the Yii framework? Does they have any differences regarding security?
m hadadi
  • 949
  • 2
  • 10
  • 22
45
votes
7 answers

How to get root directory in yii2

yii2 Question My yii2 install in d:\wamp\www\yii2store I want to get above path to save images which will be uploaded by me or users. I have pass all available arguments in Yii::getAlias('@webroot') (below are the lists of argument which I have…
Tousif Ali
  • 1,134
  • 2
  • 10
  • 14
1
2 3
99 100