Download the PHP package yllumi/ci4pageroute without Composer
On this page you can find all versions of the php package yllumi/ci4pageroute. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yllumi/ci4pageroute
More information about yllumi/ci4pageroute
Files in yllumi/ci4pageroute
Package ci4pageroute
Short Description Page based routing for CodeIgniter 4
License MIT
Informations about the package ci4pageroute
CodeIgniter 4 Page Route
Develop even more rapid with page based route. It is like Nextjs or Nuxtjs for CodeIgniter 4.
Install
- Install CodeIgniter 4
- Run composer
composer require yllumi/ci4pageroute
-
Change 2 line of Config/Routes.php in CodeIgniter like this:
- Run
composer run -d vendor/yllumi/ci4pageroute add-sample-page
to place sample pages - Happy develop!
Create Page
Page based route use Latte template engine to build page structure.
By default page is placed inside folder pages/
in root project.
To make the page work, you must create at least two files, meta.yml
and index.html
.
meta.yml
is used to define page properties and index.html
is the page template itself.
For example, create meta.yml
inside folder pages/
like this:
and create index.html
in the same place:
You can then call your app in browser and the root homepage will show those page files.
Write PHP Operation
You also can write any PHP code just like you do in controller by creating file Action.php
in the same place, with this structure:
Every data inside $data
variable you return can be called inside page template as like you do with any properties from meta.yml
.
There are at least two method inside PageAction class, run()
and process()
. Method run()
is used to write code to handle GET request of the page, and process()
is used to handle POST request to that page.
Create Subpage
You can also create any subpage by creating subfolder inside pages/
. You can then place meta.yml
, index.html
, and Action.php
inside that subfolder.
The above page structure results pages http://domain.test/ and http://domain.test/about.