Cake php

Cake php

Build faster and cleaner PHP applications. Test your knowledge of the CakePHP ecosystem, from the Bake console to advanced ORM techniques, with our 75+ MCQ challenge.


  1. What is the primary design philosophy of CakePHP?

    • Configuration over Convention
    • Convention over Configuration
    • No design rules
    • XML-based setup
  2. Which architectural pattern does CakePHP follow?

    • MVVM
    • MVC (Model-View-Controller)
    • Singleton
    • Service Provider
  3. What is the command to generate code automatically in CakePHP?

    • bin/cake generate
    • bin/cake bake
    • bin/cake create
    • bin/cake build
  4. In CakePHP 4+, where are the view files stored?

    • src/Views
    • templates/
    • webroot/
    • config/
  5. Following CakePHP conventions, what should the table name be for a model named 'User'?

    • user
    • users
    • tbl_user
    • UserTable
  6. In CakePHP ORM, what is an 'Entity'?

    • A database table
    • An object representing a single row in a table
    • A validation rule
    • A controller action
  7. Which method is used to fetch a single record by primary key?

    • find('first')
    • get()
    • first()
    • fetch()
  8. Where are the validation rules for data integrity defined?

    • Controller
    • Table class
    • Entity class
    • View
  9. What is the difference between validation and application rules?

    • None
    • Validation is for data format, Rules are for business logic (like unique email)
    • Rules are faster
    • Validation is for JS only
  10. Which association type is used when a User 'has many' Articles?

    • hasOne
    • hasMany
    • belongsTo
    • belongsToMany
  11. What is a 'Behavior' in CakePHP?

    • A controller trait
    • Reusable logic that can be attached to Table classes
    • A view helper
    • A JavaScript file
  12. Which method is used to trigger a custom event?

    • \$this->run()
    • \$this->dispatchEvent()
    • \$this->trigger()
    • event()
  13. In CakePHP, 'Dependency Injection' is primarily managed via:

    • The Service Container / Application class
    • Gii
    • ActiveRecord
    • Composer
  14. How do you perform a transaction in CakePHP?

    • begin_transaction()
    • \$connection->transactional()
    • saveAll()
    • \$this->commit()
  15. Which interface must be implemented for custom password hashing?

    • HashInterface
    • PasswordHasherInterface
    • AuthInterface
    • CryptInterface