require APPPATH.'../vendor/autoload.php';
One line in bootstrap.php. This month it became the whole strategy for a project we decided to keep on Kohana.
The framework is quiet, the project is alive. These two facts have to coexist somehow. The plan: nothing new gets written the Kohana way. New dependencies come through Composer, and Kohana’s autoloader and Composer’s autoloader live together fine.
First candidate was the HTTP client. We talk to two external APIs, and the code around Request_Client_External was not pretty. Guzzle is better in every way. But Guzzle does not spread through the codebase. There is an interface:
interface Http_Client {
public function get($url, array $options = array());
public function post($url, array $options = array());
}
and one adapter class with Guzzle inside. Application code sees only the interface.
Two things for the price of one small wrapper. Unit tests need no network and no Kohana, you pass a fake client and test the logic. And the day we leave Kohana, this code does not notice. It has no idea what framework it runs in.
Mailer is next. Then the logger.
I do not call this a migration. Nobody approved a migration, there is no budget for a rewrite, and rewrites of working systems mostly end badly anyway. Every month a little more of the application depends on packages and interfaces, and a little less on Kohana. If the framework dies completely, the surface we have to replace is shrinking while we do normal feature work.
The honest part: I wanted the rewrite. The wrapper felt like giving up. A month in, the wrapper is the only thing that shipped.
Strangle it slowly. The framework will not mind.