Notes on recording roles in yii2
Today I wrote an RBAC application for yii2. I planned to simply modify the original records about roles to switch to new permissions, but then an error occurred:
After eliminating the problem of permission structure (permission name, role name, authManager type used), I think the problem is caused by changing the data of the recorded role. The original recorded permission data is as follows:
Since it is a serialized array of PHP, then in the original array, regardless of the subscript or value, it will appear in the form of a value (string) after serialization. Their subscripts are all their own lengths (so it is also explained that O:30 refers to the words consolebacProfileAccessRule, which have 30 letters in total, and those represented by numbers do not need to indicate their length, such as i:1460293714;). The solution is very simple, mainly the serialization format problem. The modified permission record is as follows:
When it comes to writing code, it means to figure out what is in it, and then work it out from the work steps one by one~ I hope these trivial problems will not bother you After all, we have been thinking about it for so long. If we don't make mistakes, we may have written more innovative code.
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });The above has introduced the pitfalls of yii2 and php (de)serialization, including the content of yii and php. I hope it will be helpful to friends who are interested in PHP tutorials.