Yii v2 snippet guide III

Comparing #36 with #37

Revision #37 was created by rackycz rackycz on Feb 18, 2021, 10:12:10 AM.

Replace

Content

[...]
],
],
```
Now the language-switching links will produce URL like this: http://myweb.com/en/site/index . Without the rules the link would look like this: http://myweb.com/site/index?sys_lang=en . So the rule works in both directions. When URL is parsed and controllers are called, but also when a new URL is created using the URL helper.

**Search and replace
 Yii::t()** --- Simple usage in format Yii::t('text','text') can be searched using following regex for example in Notepad++. If you want to modify it massively, you can use the "replace" command, also in Notepad++. **Yii::t()**
 
``` search: Yii::t\('([^']*)'[^']*'([^']*)'[^\)]*\) replace with: Yii::t\('$1','$2'\) ``` **URLs (in Notepad++) **
 
```
 
return $this->redirect('/controller/action')->send(); // NO
 
return $this->redirect(['controller/action'])->send(); // YES
 
 
search: ->redirect\(['][/]([^']*)[']\)
 
replace: ->redirect\(['$1']\)
 
 
====
 
 
return $this->redirect('controller/action')->send(); // NO
 
return $this->redirect(['controller/action'])->send(); // YES
 
 
search: ->redirect\((['][^']*['])\)
 
replace: ->redirect\([$1]\)
 
```
 
 
**Running Yii project in Vagrant. (Simplified version)**
---
- Do you want your colleague-developers to use identical environment like you have?
- Or do you want to easily setup whole server after you reinstalled your computer?

This is when Vagrant is helpful.
[...]