Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cakefest 2024 Workshop 1

Cakefest 2024 Workshop 1

Transcript

  1. Workshop 1 • 3h session • Quick CakePHP project setup

    • Building a plugin from scratch: Report builder • Code https:/ /github.com/steinkel/cakefest2024 • Database https:/ /github.com/steinkel/cakefest2024/blob/master/db.sql • Slides
  2. Setup dev environment • Requirements $ sudo apt install -y

    php-cli php-intl php-mbstring php-sqlite3 zip php-zip // setup composer 5
  3. Composer • Create a CakePHP 5 project • https:/ /github.com/cakephp/app

    $ composer create-project cakephp/app cakefest2024 Installing... … Do you want to remove the existing VCS (.git, .svn..) history? [Y,n]? ←Y {skeleton} 7
  4. Configuration • Application class • CakePHP Bootstrap • config/bootstrap.php •

    config/app.php • Configure default datasource via environment (done for you by ddev in .env) 9
  5. $ bin/cake bake all --everything --prefix Admin (you will need

    to setup Admin prefix routing) Bake Shell • Build a CRUD for our tables 11
  6. 15

  7. 16

  8. 17

  9. 18

  10. 19

  11. 20

  12. • bin/cake bake migration initial --plugin ReportBuilder cake bake model

    --table rb_reports Reports --plugin ReportBuilder cake bake controller Reports --plugin ReportBuilder cake bake template Reports --plugin ReportBuilder Start with a migration 22
  13. • Create new table to store the associations • Use

    Ajax to save associations • Do not save duplicated associations Add association (save) 26
  14. • Add new type to store comma separated values to

    store the selected columns Create new Database Type 27
  15. • Use the associations to select the columns for the

    report • Save the selected columns as comma separated Select columns 28
  16. • Store the filters as json • Add a filter

    widget for the starting table Add filter widget 31
  17. • Create logic to parse the filters and apply them

    to the query executed Apply filters to report run 32
  18. • In case we want to fetch the data using

    an endpoint Add a simple API 36
  19. • In case we want to fetch the data using

    an endpoint Add a simple API 38
  20. • Create a widget to provide autocomplete filter for associations

    following conventions Autocomplete association 41