Q. Which method should be called at the end of index.php?

  • (A) init()
  • (B) boot()
  • (C) start()
  • (D) run()
πŸ’¬ Discuss
βœ… Correct Answer: (C) start()
Explanation: start() ensures all configurations are loaded.

Q. Which class is used to create routes?

  • (A) App
  • (B) Router
  • (C) Request
  • (D) Logger
πŸ’¬ Discuss
βœ… Correct Answer: (B) Router
Explanation: TrishulApi\Core\Http\Router handles route creation.

Q. How do you define a GET route in Trishul API?

Code:
Router::get('/hello', ["hello"=>"world"]);
  • (A) Router::create('/hello')
  • (B) Router::post('/hello')
  • (C) Router::get('/hello', [...])
  • (D) Router::route('/hello')
πŸ’¬ Discuss
βœ… Correct Answer: (C) Router::get('/hello', [...])
Explanation: Router::get() is used to define GET routes.

Q. Which class provides access to HTTP request data?

  • (A) Response
  • (B) Request
  • (C) Router
  • (D) DB
πŸ’¬ Discuss
βœ… Correct Answer: (B) Request
Explanation: Request class provides headers, body, and query parameters.

Q. How is the Request object provided to controllers?

  • (A) Manually instantiated
  • (B) Injected automatically via constructor
  • (C) Fetched from global variable
  • (D) Loaded via config file
πŸ’¬ Discuss
βœ… Correct Answer: (B) Injected automatically via constructor
Explanation: Request object is automatically injected into the controller constructor.

Q. Which method retrieves request headers?

  • (A) body()
  • (B) query_params()
  • (C) header()->get()
  • (D) getHeaders()
πŸ’¬ Discuss
βœ… Correct Answer: (C) header()->get()
Explanation: header()->get() is used to fetch header values.

Q. Which class is used to send JSON responses?

  • (A) Request
  • (B) Response
  • (C) Router
  • (D) Logger
πŸ’¬ Discuss
βœ… Correct Answer: (B) Response
Explanation: Response::json() is used to return JSON responses.

Q. Which method is used to return JSON response?

Code:
Response::json(HttpStatus::OK, [...])
  • (A) Response::send()
  • (B) Response::json()
  • (C) Response::output()
  • (D) Response::return()
πŸ’¬ Discuss
βœ… Correct Answer: (B) Response::json()
Explanation: Response::json() is specifically used for JSON output.

Q. Which class is used for logging?

  • (A) Logger
  • (B) LoggerFactory
  • (C) LogManager
  • (D) Debug
πŸ’¬ Discuss
βœ… Correct Answer: (B) LoggerFactory
Explanation: LoggerFactory provides logging instances.

Q. Which logging level method is NOT mentioned?

  • (A) info()
  • (B) warn()
  • (C) error()
  • (D) debug()
πŸ’¬ Discuss
βœ… Correct Answer: (D) debug()
Explanation: Docs mention info, warn, error but not debug.