PHP code example of yllumi / ci4-pages

1. Go to this page and download the library: Download yllumi/ci4-pages 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/ */

    

yllumi / ci4-pages example snippets


protected $helpers = ['Yllumi\Ci4Pages\Helpers\pageview'];



namespace App\Pages\home;

use App\Controllers\BaseController;

class PageController extends BaseController
{
    public function getIndex($name = null): string
    {
        $data['name'] = $name ?? 'World';

        return pageView('home/index', $data);
    }

    public function getDetail($id = null)
    {
        $data['name'] = 'Toni Haryanto';
        $data['id'] = $id;

        return pageView('home/detail', $data);
    }

}

<h1>Hello <?= $name 



namespace App\Pages\profile;

use App\Controllers\BaseController;

class PageController extends BaseController
{
    use \CodeIgniter\API\ResponseTrait;

    public function getIndex()
    {
        $data['name'] = 'Toni Haryanto';
        $data['city'] = 'Bandung';

        return $this->respond($data);
    }

    public function getDetail($id = null)
    {
        $data['name'] = 'Toni Haryanto';
        $data['city'] = 'Bandung';
        $data['id'] = $id;

        return $this->respond($data);
    }
}
plaintext
app/
├── Pages/
│   ├── home/
│   │   ├── PageController.php
│   │   ├── index.php
│   ├── profile/
│   │   ├── PageController.php
│   │   ├── index.php
│   │   ├── achievement/
│   │   │   ├── PageController.php
│   │   │   ├── index.php

php spark page:create pagename
php spark page:create pagename/subpage