Interactive Console (REPL)

The CakePHP app skeleton comes with a built in REPL(Read Eval Print Loop) thatmakes it easy to explore some CakePHP and your application in an interactiveconsole. You can start the interactive console using:

  1. bin/cake console

This will bootstrap your application and start an interactive console. At thispoint you can interact with your application code and execute queries using yourapplication’s models:

  1. bin/cake console
  2.  
  3. >>> $articles = Cake\ORM\TableRegistry::getTableLocator()->get('Articles');
  4. // object(Cake\ORM\Table)(
  5. //
  6. // )
  7. >>> $articles->find()->all();

Since your application has been bootstrapped you can also test routing using theREPL:

  1. >>> Cake\Routing\Router::parse('/articles/view/1');
  2. // [
  3. // 'controller' => 'Articles',
  4. // 'action' => 'view',
  5. // 'pass' => [
  6. // 0 => '1'
  7. // ],
  8. // 'plugin' => NULL
  9. // ]

You can also test generating URL’s:

  1. >>> Cake\Routing\Router::url(['controller' => 'Articles', 'action' => 'edit', 99]);
  2. // '/articles/edit/99'

To quit the REPL you can use CTRL-C or by typing exit.