-
Notifications
You must be signed in to change notification settings - Fork 4
Facade
そら edited this page Nov 29, 2017
·
3 revisions
Facades provide a "static" interface to classes that are available in the application's service container.
All of Kotori's facades are defined in the Kotori\Facade
namespace. So, we can easily access a facade like so:
use Kotori\Facade\Cache;
use Kotori\Facade\Request;
use Kotori\Facade\Response;
if (Request::get('hello') == 'world') {
Cache::set('name', 'niconiconi');
} else {
Response::setStatus(400);
}
Below you will find every facade and its underlying class. The service container binding key is also included where applicable.
Facade | Class | Service Container Binding |
---|---|---|
Cache | Kotori\Core\Cache | cache |
Config | Kotori\Core\Config | config |
Request | Kotori\Http\Request | request |
Response | Kotori\Http\Response | response |
Route | Kotori\Http\Route | route |
You can use DI in controllers.
namespace app\controllers;
use Kotori\Core\Controller;
use Kotori\Http\Request;
class Blog extends Controller {
public function index(Request $request)
{
echo $request->get('var');
}
}