A REST server in Zend Framework in three lines
How Zend Framework 1 exposed a PHP class as a REST service, and what to use today.
From the archive: first published on mohamedsharaf.net in May 2012. Rewritten and checked in 2026; some details may be out of date.
Zend Framework 1 made a basic REST service almost free: write a normal PHP class, and Zend_Rest_Server exposes its public methods over HTTP. Inside a controller action:
$server = new Zend_Rest_Server();
$server->setClass('ProductService');
$server->handle();
A request like /api?method=findProduct&id=42 calls ProductService::findProduct(42) and returns the result as XML.
Today: Zend Framework 1 is long retired (the project continues as Laminas), and most APIs now speak JSON with proper HTTP methods and status codes (see HTTP methods in plain words). The lesson still holds: keep your business logic in plain classes, and let a thin layer handle the web part.