PHP code example of trianayulianto / inertia-codeigniter-4
1. Go to this page and download the library: Download trianayulianto/inertia-codeigniter-4 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
trianayulianto / inertia-codeigniter-4 example snippets
namespace App\Filters;
use CodeIgniter\Filters\FilterInterface;
use CodeIgniter\HTTP\Request;
use Inertia\Middleware;
class HandleInertiaRequests extends Middleware implements FilterInterface
{
/**
* The root template that is loaded on the first page visit.
*
* @var string
*/
protected $rootView = 'app';
/**
* Determine the current asset version.
*
* @param \CodeIgniter\HTTP\Request $request
* @return string|null
*/
public function version(Request $request)
{
return parent::version($request);
}
/**
* Define the props that are shared by default.
*
* @param \CodeIgniter\HTTP\Request $request
* @return array
*/
public function share(Request $request)
{
return array_merge(parent::share($request), []);
}
}
use Inertia\Inertia;
class EventsController extends Controller
{
public function show($id)
{
$event = Event::find($id);
return Inertia::render('Event/Show', [
'event' => $event,
]);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.