li3_cake / branches / master / readme.wiki

history
# Li3_Cake _Integrating the most rad framework with CakePHP_ The `li3_cake` plugin allows you to develop applications that use CakePHP and Lithium together, leveraging classes and exposing resources using both frameworks in unison. First, get a fresh copy of CakePHP by downloading or cloning, and install it in `app/libraries/cakephp` or `/libraries/cakephp` (this director should contain `app`, `cake`, etc). Then load the `li3_cake` plugin in your bootstrap file: {{{ Libraries::add('plugin', 'li3_cake'); }}} Finally, since CakePHP will also try to load `bootstrap.php`, we need to add a check at the top to make sure it doesn't get executed twice: {{{ if (defined("LITHIUM_APP_PATH")) { return true; } }}} Finally, we can return to `webroot/index.php`, where you have a couple of options. If you're only using Lithium classes, and not dispatching to any Lithium controllers, you can simply call CakePHP's dispatcher, as you normally would: {{{ <?php require dirname(__DIR__) . '/config/bootstrap.php'; $dispatcher = new Dispatcher(); $dispatcher->dispatch(); ?> }}} Alternatively, you can set it up such that requests are dispatched to Lithium first, and then to Cake, if no Lithium controllers can respond to the request: {{{ <?php require dirname(__DIR__) . '/config/bootstrap.php'; try { echo lithium\action\Dispatcher::run(); } catch (Exception $e) { if ($e->getMessage() == 'Could not route request') { $dispatcher = new Dispatcher(); $dispatcher->dispatch(); } } ?> }}} This allows you to replace only specific parts of your CakePHP application with Lithium controllers or responders, or incrementally migrate your application to Lithium.