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
50
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
  • 5,433
  • 4
  • 33
  • 37
50
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,214
  • 2
  • 11
  • 15
49
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
  • 602
  • 1
  • 5
  • 9
49
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
  • 12,262
  • 10
  • 69
  • 70
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
46
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
  • 4,332
  • 13
  • 54
  • 93
41
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.
Nahid Hossain
  • 772
  • 2
  • 7
  • 20
41
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,439
  • 1
  • 28
  • 54
41
votes
13 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
  • 3,204
  • 5
  • 39
  • 52
40
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
  • 497
  • 1
  • 5
  • 11
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
  • 2,196
  • 4
  • 29
  • 42
39
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
  • 692
  • 1
  • 8
  • 14
39
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
  • 19,449
  • 54
  • 157
  • 290
37
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
  • 502
  • 3
  • 13
  • 28
37
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
  • 657
  • 1
  • 6
  • 18