Silex 是一个PHP 5.3的微型框架。基于Symfony2 和 Pimple 构建。同时还受到sinatra的启发。
A microframework provides the guts for building simple single-file apps. Silex aims to be:
- Concise: Silex exposes an intuitive and concise API that is fun to use.
- Extensible: Silex has an extension system based around the Pimple micro service-container that makes it even easier to tie in third party libraries.
- Testable: Silex uses Symfony2's HttpKernel which abstracts request and response. This makes it very easy to test apps and the framework itself. It also respects the HTTP specification and encourages its proper use.
示例代码:
1 require_once __DIR__.'/../vendor/autoload.php'; 2 3 $app = new Silex\Application(); 4 5 $app->get('/hello/{name}', function($name) use($app) { 6 return 'Hello '.$app->escape($name); 7 }); 8 9 $app->run();