Q. What happens if start() is not called in index.php?

  • (A) Routes will still work
  • (B) Application will not initialize properly
  • (C) Only middleware fails
  • (D) Only DB fails
πŸ’¬ Discuss
βœ… Correct Answer: (B) Application will not initialize properly
Explanation: start() is required to load all configurations and boot the application.

Q. Which method is responsible for setting custom exception handling?

  • (A) set_env_path()
  • (B) set_exception_handler()
  • (C) set_log_dir()
  • (D) handle_exception()
πŸ’¬ Discuss
βœ… Correct Answer: (B) set_exception_handler()
Explanation: Used to define global exception handling.

Q. What is the role of set_log_dir()?

  • (A) Defines DB location
  • (B) Stores request logs in memory
  • (C) Sets directory for log files
  • (D) Prints logs to console
πŸ’¬ Discuss
βœ… Correct Answer: (C) Sets directory for log files
Explanation: Logs are stored in files in the defined directory.

Q. What does get_swagger() return?

  • (A) JSON response
  • (B) Router object
  • (C) Swagger documentation handler
  • (D) Request object
πŸ’¬ Discuss
βœ… Correct Answer: (C) Swagger documentation handler
Explanation: Returns TrishulSwagger instance for API documentation.

Q. Which file is responsible for defining routes?

  • (A) .env
  • (B) composer.json
  • (C) index.php
  • (D) README.md
πŸ’¬ Discuss
βœ… Correct Answer: (C) index.php
Explanation: Routes are defined in index.php using Router.

Q. What is returned when you define a route like Router::get('/hello', ['hello'=>'world'])?

  • (A) HTML page
  • (B) Plain text
  • (C) JSON response
  • (D) Binary data
πŸ’¬ Discuss
βœ… Correct Answer: (C) JSON response
Explanation: Returns JSON response automatically.

Q. Which method fetches query parameters from URL?

  • (A) body()
  • (B) query_params()
  • (C) params()
  • (D) getQuery()
πŸ’¬ Discuss
βœ… Correct Answer: (B) query_params()
Explanation: query_params() returns URL query parameters.

Q. Which method retrieves request body?

  • (A) getBody()
  • (B) body()
  • (C) payload()
  • (D) data()
πŸ’¬ Discuss
βœ… Correct Answer: (B) body()
Explanation: body() returns request payload.

Q. How are headers set in middleware response?

  • (A) $response->setHeader()
  • (B) $response->header()->set()
  • (C) $response->addHeader()
  • (D) $response->putHeader()
πŸ’¬ Discuss
βœ… Correct Answer: (B) $response->header()->set()
Explanation: Headers are set using header()->set().

Q. What happens if middleware does not return Request in handle()?

  • (A) It still works
  • (B) Breaks request flow
  • (C) Only headers fail
  • (D) Only response fails
πŸ’¬ Discuss
βœ… Correct Answer: (B) Breaks request flow
Explanation: Middleware must return Request to continue processing.