Developer documentation for the lightweight, PHP-FPM-oriented Bhitti framework.
layout: default title: Upgrade from v0.2.0 ————————–
Bhitti v0.3.0 introduces three developer-facing changes.
Previously:
public function index(): string
{
return view('users.index', [
'users' => $users,
]);
}
Use:
public function index(): Response
{
return response()->view('users.index', [
'users' => $users,
]);
}
Import the response class when using a return type:
use Bhitti\Http\Response;
For a non-200 response:
public function notFound(): Response
{
return response()
->view('errors.404')
->status(404);
}
v0.3.0 adds official Twig support.
Install Twig in applications that want to use it:
composer require twig/twig
Render a Twig template:
public function index(): Response
{
return response()->twig('users.index', [
'users' => $users,
]);
}
Without a .twig suffix, the default HTML template is resolved as:
resources/views/users/index.html.twig
Explicit Twig filenames can also be used:
return response()->twig('feeds/rss.xml.twig', $data);
For non-HTML output:
return response()
->twig('feeds/rss.xml.twig', $data)
->header('Content-Type', 'application/xml');
Native PHP templates remain available:
resources/views/*.view.php
Controller methods that previously returned rendered view strings:
public function index(): string
{
return view('users.index');
}
should now return Response:
public function index(): Response
{
return response()->view('users.index');
}
The same applies to Twig:
public function index(): Response
{
return response()->twig('users.index');
}
Update:
return view('example');
to:
return response()->view('example');
Change the controller return type:
string
to:
Response
and add:
use Bhitti\Http\Response;
When using Twig:
composer require twig/twig
Then:
return response()->twig('example');
No other application changes are required for this release.