Yii 2 Basic Final Demo (PDF)




File information


Author: กฤษณวัฒน์ แก้วแสนเมือง

This PDF 1.5 document has been generated by Microsoft® Word 2016, and has been sent on pdf-archive.com on 19/12/2016 at 15:44, from IP address 116.58.x.x. The current document download page has been viewed 842 times.
File size: 1.99 MB (60 pages).
Privacy: public file
















File preview


Phpreff.com

สารบัญ
คำนำ ............................................................................................................................................. 1
ปฐมบท .......................................................................................................................................10
ติดตั้ง composer ...................................................................................................................10
basic template และ advance template ..............................................................................14
การติดตั้ง Yii 2 Basic Template ............................................................................................15
โครงสร้างโฟลเดอร์ของ Yii2 Basic Template ..........................................................................18
การติดตัง้ advance template ................................................................................................19
Hello World .........................................................................................................................23
Application Object....................................................................................................................24
ไฟล์ Index.php .....................................................................................................................25
Applications Object คืออะไร .........................................................................................25
Application Configurations การแนบการตั้งค่าภายนอก .....................................................26
Application Properties ตัวแปรหลักของ Application ......................................................26
Language ......................................................................................................................29
Modules ........................................................................................................................29
Params ..........................................................................................................................29
Timezone ......................................................................................................................30
Application Events event ที่ทางานระดับ global .............................................................30
Application Lifecycle ผังการทางานของ object ................................................................33
Controller ..................................................................................................................................35
สร้าง controller ...............................................................................................................36

การตั้งชื่อ controller .........................................................................................................36
Action คืออะไร................................................................................................................37
การเรี ยกใช้งาน ..................................................................................................................37
ผลการทางานของ Action ...................................................................................................38
การใช้งานพารามิเตอร์ .........................................................................................................38
ข้อแนะนาในการใช้งาน .......................................................................................................40
Model ........................................................................................................................................41
การสร้าง Model ...............................................................................................................42
Attribute ........................................................................................................................43
Attribute Label ..............................................................................................................43
Scenarios ......................................................................................................................44
การตรวจสอบค่าที่เข้ามา ......................................................................................................45
Massive Assignment ....................................................................................................46
View ..........................................................................................................................................48
การสร้าง view ..................................................................................................................49
ทาความรู ้จกั กับ เลเอาท์ .......................................................................................................49
การใช้งาน Block ..............................................................................................................51
View Component ..........................................................................................................52
Active Form คืออะไร ......................................................................................................52
การตั้งชื่อของหน้า ..............................................................................................................56
การตั้ง meta tags ............................................................................................................56
Event ของ View ..............................................................................................................56
แนวทางการใช้งาน .............................................................................................................57
Modules ....................................................................................................................................58
การสร้าง Modules ...........................................................................................................60

การสร้าง module ...............................................................................................................60
Module ที่น่าสนใจ ............................................................................................................64
Filter ..........................................................................................................................................65
การใช้งานแบบง่ายๆ ...........................................................................................................66
ทดลองสร้าง filter .............................................................................................................66
Filter ที่เราควรรู ้จกั ไว้ ........................................................................................................68
Widget .......................................................................................................................................70
การตั้งค่าที่สาคัญ ................................................................................................................75
ลองสร้าง Asset ................................................................................................................75
กาหนดให้วาง Javascript ไว้บนส่ วน head ........................................................................77
การแคชไฟล์ดว้ ย timestamp .............................................................................................78
Asset ที่ใช้งานกันบ่อย ......................................................................................................79
Extensions ................................................................................................................................80
การติดตั้ง Extension.........................................................................................................81
วิธีการใช้งาน .....................................................................................................................82
Request.....................................................................................................................................84
การจัดการพารามิเตอร์ .........................................................................................................85
การจัดการ URL .................................................................................................................85
จัดการ HTTP Header ......................................................................................................86
ตรวจสอบชนิดของคาร้องขอ ................................................................................................86
ดึงข้อมูลของผูใ้ ช้งาน ..........................................................................................................87
Response ..................................................................................................................................88
การใช้งาน Http status code ...........................................................................................89
ส่ งข้อความแสดงข้อผิดพลาด................................................................................................89

รายการข้อผิดพลาดที่สามารถใช้ได้ท้ งั หมด .............................................................................89
กาหนดค่าให้ header .........................................................................................................90
การตั้งรู ปแบบของคาร้องขอ .................................................................................................90
การส่ งไปยังหน้าอื่นๆ..........................................................................................................91
การดาวน์โหลดไฟล์............................................................................................................91
Session & Cookie .....................................................................................................................92
การดึงค่าใน session .........................................................................................................93
Cookies ...............................................................................................................................94
การส่ งไปยังบราวเซอร์ ........................................................................................................94
การอ่านค่า ........................................................................................................................95
การตรวจสอบ Cookies .....................................................................................................95
การจัดการข้อผิดพลาด ....................................................................................................................96
การเก็บประวัติการใช้งาน Logging ...............................................................................................100
ชนิดของ log ...................................................................................................................101
การใช้งานเบื้องต้น ...........................................................................................................101
เก็บไว้ที่ไหนดี .................................................................................................................102
Alias ........................................................................................................................................103
การสร้าง alias ......................................................................................................................104
การใช้รวมๆ กัน.....................................................................................................................105
Alias หลักของระบบ .............................................................................................................105
Database Access Object .......................................................................................................107
สร้างการเชื่ อมต่อ ...................................................................................................................108
การคิวรี่ เบื้องต้น.....................................................................................................................108
การเพิ่มพารามิเตอร์ ..........................................................................................................109

การใช้งานฟังก์ชนั excute ................................................................................................109
การจัดการตาราง ....................................................................................................................110
Query Builder..........................................................................................................................112
select ...........................................................................................................................113
from .............................................................................................................................113
where...........................................................................................................................114
orderBy ........................................................................................................................115
groupBy .......................................................................................................................115
having..........................................................................................................................115
limit และ offset............................................................................................................115
join ...............................................................................................................................116
union ...........................................................................................................................116
ฟังก์ชนั อื่นๆ ....................................................................................................................116
Active Record .........................................................................................................................118
การสร้าง Active record class .............................................................................................119
การคิวรี ขอ้ มูลเบื้องต้น ............................................................................................................119
การเข้าถึงข้อมูล .....................................................................................................................120
การแปลงค่าก่อนและหลังการคิวรี .......................................................................................120
การแปลงผลการค้นหาเป็ นอาเรย์ .........................................................................................121
การบันทึกและแก้ไขข้อมูล.......................................................................................................122
การลบข้อมูล .........................................................................................................................122
Migration ................................................................................................................................123
การสร้าง Migrations ...........................................................................................................124
การสร้างหรื อลบตาราง ...........................................................................................................124
ถ้าเป็ นการลบตาราง ..........................................................................................................125

การใช้ command line เพื่อเพิ่มคอลัมน์ .............................................................................126
การเพิ่มคอลัมน์ ................................................................................................................126
การลบคอลัมน์ .................................................................................................................127
รวมฟังก์ชนั ที่ใช้ในการจัดการตาราง ....................................................................................127
การใช้งาน migration ...........................................................................................................128
การ revert migration .........................................................................................................129
ยกเลิก การ revert Migrations ..............................................................................................129
ดูประวัติการใช้งาน.................................................................................................................130
การอัพโหลดไฟล์ ........................................................................................................................131
สร้าง Model ........................................................................................................................132
สร้าง action ........................................................................................................................132
การจัดการรู ปแบบของข้อมูล..........................................................................................................134
การตั้งค่าเบื้องต้น ...................................................................................................................135
การจัดรู ปแบบให้วนั เวลา .........................................................................................................135
การจัดรู ปแบบตัวเลข ..............................................................................................................136
การแสดงผลตามท้องถิ่น..........................................................................................................136
Pagination การแบ่งหน้าการแสดงผล ...........................................................................................137
การใช้งานเบื้องต้น ...........................................................................................................138
การใช้งานร่ วมกับ DataProvider ......................................................................................139
Sorting การเรี ยงลาดับข้อมูล ........................................................................................................141
การใช้งานเบื้องต้น ...........................................................................................................142
Data Providers .......................................................................................................................143
Active Data Provider ........................................................................................................144
การใช้งานเบื้องต้น ...........................................................................................................144

SQL Data Provider............................................................................................................145
การใช้งานเบื้องต้น ...........................................................................................................145
Array Data Provider .........................................................................................................146
ตัวอย่างการใช้งานเบื้องต้น .................................................................................................146
Data widgets ..........................................................................................................................148
DetailView .........................................................................................................................149
การใช้งานเบื้องต้น ...........................................................................................................149
ListView ..................................................................................................................................
GridView............................................................................................................................149
การใช้งานเบื้องต้น ...........................................................................................................149
เลือกคอลัมน์ที่จะมาแสดง ..................................................................................................151
การจัดการ Theme .....................................................................................................................152
การเปลี่ยนธีม ..................................................................................................................153
การสร้างธีม ....................................................................................................................154
การจัดการๆเข้าสู่ ระบบAuthentication ........................................................................................162
การใช้งานในเบื้องต้น .......................................................................................................163
การล็อกอินจากฐานข้อมูล ..................................................................................................167
การจัดการสิ ทธิในการเข้าถึงAuthorization ....................................................................................169
Access Control Filter ..................................................................................................170
Extension ที่ช่วยจัดการ rbac ..........................................................................................173
การจัดการแคช Caching..............................................................................................................175
Data caching.....................................................................................................................176
Cache ชนิ ดต่างๆ............................................................................................................176
ฟังก์ชนั ที่ใช้ในการแคช .....................................................................................................176
การกาหนดเวลาหมดอายุ ...................................................................................................177

การแคชข้อมูลจากการคิวรี .................................................................................................177
Fragment caching ............................................................................................................177
การกาหนดอายุให้แคช ......................................................................................................177
การใช้งานตามเงื่อนไข ......................................................................................................177
การแสดงเนื้ อหาที่เปลี่ยนแปลงตลอด ...................................................................................178
Page caching ....................................................................................................................178
HTTP caching ...................................................................................................................178

Chapter 1






Download Yii 2 Basic Final Demo



Yii 2 Basic Final Demo.pdf (PDF, 1.99 MB)


Download PDF







Share this file on social networks



     





Link to this page



Permanent link

Use the permanent link to the download page to share your document on Facebook, Twitter, LinkedIn, or directly with a contact by e-Mail, Messenger, Whatsapp, Line..




Short link

Use the short link to share your document on Twitter or by text message (SMS)




HTML Code

Copy the following HTML code to share your document on a Website or Blog




QR Code to this page


QR Code link to PDF file Yii 2 Basic Final Demo.pdf






This file has been shared publicly by a user of PDF Archive.
Document ID: 0000524147.
Report illicit content