17 Oct 2015

[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:

  1. phalcon --help -> thông tin các lệnh
  2. phalcon project <project name> Tạo 1 project mới tại thư mục hiện hành
    1. phalcon project --type=modules -> tạo project multi modules
  3. phalcon create-controller --name <Controller name> hoặc
    phalcon controller <Controller name>
    ->
    tạo 1 controller
    1. phalcon controller <Controller name> --directory=<folder of controller>
    2. phalcon controller <Controller name> --base-class=<extends class>
  4. phalcon model <Table name>
    -> Tạo 1 model mới (Note: đã có table trong database)
  5. 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
  6. phalcon all-models -> Tạo tất cả các model từ các bảng có trong database
  7. phalcon webtools enable -> Bật webtool lập trình truy cập domain/webtools.php để sử dụng
  8. 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
    migration param
    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