# Importing Kohana as a Library If you're working with an existing codebase it's often difficult to modernise the code as it would mean a complete rewrite and there's rarely the time. An alternative is to improve the codebase incrementally as best you can, gradually outsourcing code to external libraries to reduce the amount of old code there is to maintain. This tutorial describes how to include the Kohana PHP framework into existing PHP applications, without having to use the routing and HMVC request handling features. [!!] The code modified in this tutorial was copied from Kohana version 3.1.x. You may need to update it to work with future releases. In normal usage of the Kohana framework, the `index.php` file acts as the request handler; it sets up the environment, loads the system configuration, and then handles the request (see [Request Flow](flow)). We'll walk you through the steps required to create a file we'll call `include.php` which will allow you to include Kohana from exiting PHP applications. ## Demo application The following file will serve as our (insultingly simple) demo application for this tutorial. ### File: `demo.php` ~~~