Skip to content

Instantly share code, notes, and snippets.

@tuannguyen29
Last active February 21, 2020 02:20
Show Gist options
  • Save tuannguyen29/61b939bddccfa0c7f71e8f9431eda24e to your computer and use it in GitHub Desktop.
Save tuannguyen29/61b939bddccfa0c7f71e8f9431eda24e to your computer and use it in GitHub Desktop.

Zend Framework 1.12.20

Tài liệu tham khảo:

Cài đặt zend bằng tay:

  • Tải library của zend về và cài đặt path global (windows) C:\wamp64\www\zend\ZendFramework-1.12.18\bin
  • Chạy lệnh zf để kiểm tra cài đặt thành công.
  • Chạy zf create project ten_project để tạo một project mới.

File Config

application/configs/application.ini

Cài đặt kết nối db:

resources.db.adapter = "PDO_MYSQL"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = "*****"
resources.db.params.dbname = "db_name"
resources.db.driver_options.charset = "utf-8"
resources.db.isDefaultTableAdapter = true

Zend Tools:

zf configure db-adapter dsn section-name[=production]


zf configure db-adapter dsn section-name[=development : production] \
> 'adapter=PDO_MYSQL&dbname=APPLICATION_PATH "/../data/db/guestbook.db"' \ 
> development : production

zf create action sign Guestbook

Tạc Action cho controller:

zf Create Action name controller-name[=Guestbook] view-included[=1] module

Lệnh tạo controller:

zf create controller Guestbook index-action-included[=1] 

View Helper: https://framework.zend.com/manual/1.12/en/zend.view.helpers.html#zend.view.helpers.initial.doctype

  • Workflow của Zend
  • Request HTTP -> htaccess -> index.php -> load "Zend/Application.php" -> load config "application.ini" -> từ config sẽ load "Bootstrap.php", controller, modules, setting database, helper ... -> view
  • Cách lấy config từ file application.ini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment