[Phalcon 2] 6. Các hàm thường dùng| Phalcon API| Các lệnh thường dùng của phalcon tool
Các lệnh terminal thường dùng trong phalcon tool và các hàm thường dùng trong phalcon
1. Phalcon tool cmd:
- phalcon --help -> thông tin các lệnh
- phalcon project <project name> Tạo 1 project mới tại thư mục hiện hành
- phalcon project --type=modules -> tạo project multi modules
- phalcon create-controller --name <Controller name> hoặc
phalcon controller <Controller name>
-> tạo 1 controller
- phalcon controller <Controller name> --directory=<folder of controller>
- phalcon controller <Controller name> --base-class=<extends class>
- phalcon model <Table name>
-> Tạo 1 model mới (Note: đã có table trong database)
- phalcon scaffold --table-name <Table name>
Giúp tạo nhanh MVC cho 1 table gồm các chức năng chính: thêm, sửa, xóa, cập nhật
-> Tạo 1 controller điều khiển tương tác với Model
-> Tạo 1 Model tương ứng với table
-> Tạo 4 view index, edit, new, search tương ứng với model
- phalcon all-models -> Tạo tất cả các model từ các bảng có trong database
- phalcon webtools enable -> Bật webtool lập trình truy cập domain/webtools.php để sử dụng
- phalcon migration tạo ra migration để cập nhật, import, export cấu trúc, dataCSDL khi di chuyển sang server mới hoặc muốn cập nhật tại 1 server hoặc table lỡ tay xóa

Example:
- Step 1: Tạo migration phalcon migration phalcon migration --action=generate
Note:CSDL đã có và đã có các table

-> Phalcon sẽ tạo ra migration version 1.0.0 đầu tiên lưu cấu trúc CSDL
- Step 2: (Chỉ để test) Xóa table trong CSDL
- Step 3: Gõ phalcon migration --action=run
-> phalcon sẽ tạo ra table mà bạn đã xóa trước đó.(đỡ mất công tạo đi tạo lại)
2. Volt function / các hàm sử dụng trong volt
- get_title() = $this->tag->getTitle() //set title
- text_field($name,'class':'class-name') => <input type="text"> //text field
- password_field($name)=> <input type="password"> //password field
- date_field($name)
- submit_button() => <input type="submit">
- flash_output() => output of flash message
- form("action name") => form
No comments:
Post a Comment
hocphalcon.blogspot.com