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
31
votes
1 answer

How to add a class to tags in a GridView

I need to add classes to td of a GridView. I've found renderTagAttributes(), but I can't find examples how to use it. Could you explain me this function or offer me other option? My gridview:
Kevin7
  • 631
  • 1
  • 7
  • 13
31
votes
5 answers

How to change label text of the ActiveField?

I have created new Yii2 basic project and want to dig in. There is a Username field on login page: I want to change label 'Username' to a custom one, e.g. 'My superb label'. I have read the…
Vadym
  • 1,067
  • 1
  • 13
  • 24
30
votes
1 answer

Maximum execution time of 120 seconds exceeded in yii2

I upload an excel file with 1000 rows, by default I have just 2 min in execution time, with that time I can upload 400 records. I get this error Maximum execution time of 120 seconds exceeded How i can modify this period in yii2 framework ?
Malki Mohamed
  • 1,578
  • 2
  • 23
  • 40
30
votes
5 answers

How to set a flash message in Yii2?

i followed this Link. My code is as follows in controller public function actionFunction4() { $this->layout="sintel"; $model= new Customers(); \Yii::$app->getSession()->setFlash('success', 'successfully got on to the…
Bloodhound
  • 2,906
  • 11
  • 37
  • 71
30
votes
5 answers

Yii2 : How to write distinct SQL query?

I want to implement following SQL queries in Yii 2 but with no success. This should give total number of unique company names: SELECT count(DISTINCT(company_name)) FROM clients And this should display company_name with client code and…
JKLM
  • 1,470
  • 3
  • 28
  • 66
30
votes
7 answers

Yii2 htaccess - How to hide frontend/web and backend/web COMPLETELY

I think I am pretty close. I have the htaccess redirecting to the website (frontend/web) and the /admin path (backend/web). The site appears fine, CSS files loading, etc. If you go to: http://localhost/yii2app/ - it loads the homepage, and doesn't…
Wade
  • 3,757
  • 2
  • 32
  • 51
30
votes
5 answers

Get the name of the user in yii2

How can I get the name of the logged-in-user in yii2? I can get the user-id with Yii::$app->user->id; and I know that I could find the name in the database but I want a direct way. The name-column in the database has the name "username", but…
Patricia
  • 2,885
  • 2
  • 26
  • 32
29
votes
2 answers

Yii2 - ActiveForm ajax submit

How can i use ActiveForm with these requirements? Submit form with ajax. Before submitting with ajax: Check if error exits. After submitting: Display error of field under field's input if the server responses unsuccess saving result.
29
votes
4 answers

How to enable and disable sort in Yii2 GridView?

How to enable and disable sort in Yii2 GridView ?
rdanusha
  • 913
  • 3
  • 15
  • 24
28
votes
5 answers

Yii2 BootstrapAsset is not loading bootstrap.js

yii\bootstrap\BootstrapAsset is not loading bootstrap.js, and such elements as "modal" and others are not working. class AppAsset extends AssetBundle { public $basePath = '@webroot'; public $baseUrl = '@web'; public $css = [ …
ccdiego5
  • 666
  • 1
  • 7
  • 15
28
votes
3 answers

Yii2 how does search() in SearchModel work?

Please can someone explain how the search method in a Yii2 SearchModel works? I generated it using Gii. Here it is: public function search($params){ $query = MyModel::find(); $dataProvider = new ActiveDataProvider([ 'query' =>…
Mr Goobri
  • 1,449
  • 5
  • 19
  • 42
27
votes
18 answers

FCM push notification issue: "error":"NotRegistered"

I am getting weird issue of sending push notification to Android using FCM. Goal :- Having error while sending push notification Below is the scenario I do have function for sending push notification to Android public static function…
Shashank Shah
  • 2,077
  • 4
  • 22
  • 46
27
votes
4 answers

Securing non authenticated REST API

I have been reading about securing REST APIs and have read about oAuth and JWTs. Both are really great approaches, but from what I have understood, they both work after a user is authenticated or in other words "logged in". That is based on user…
Eric B.
  • 4,622
  • 2
  • 18
  • 33
27
votes
1 answer

Yii2: How to use orWhere in andWhere

I want create this query with yii2 search model select * from t1 where (title = 'keyword' or content = 'keyword') AND (category_id = 10 or term_id = 10 ) But I don't know how to use orFilterWhere and andFilterWhere. My code…
ingenious
  • 764
  • 2
  • 8
  • 24
27
votes
2 answers

Yii2 - How To Add a CSS class to an ActiveForm Field

This is the activeform field. I would like to know how to add a css class to it. field($model, 'url')->label(false); ?>
Omar Tariq
  • 7,536
  • 10
  • 38
  • 57