Welcome Guest, Not a member yet? Register   Sign In
Using Viewi and CI4
#1

I recently came across Viewi https://viewi.net/ A package to add interactivity to an app using PHP. It's similar to Laravel's Livewire. I gave it a go and try to see if it will work with CI4. I got the pages to render but i noticed the Viewi routes are overiding CI routes depending on which one is intialized first in public/index.php.

PHP Code:
/*
 *---------------------------------------------------------------
 * LAUNCH THE APPLICATION
 *---------------------------------------------------------------
 * Now that everything is setup, it's time to actually fire
 * up the engines and make this app do its thang.
 */
// Viewi application here
include __DIR__ '/../viewi-app/viewi.php';
Viewi\App::handle();

$app->run(); 
Is there any where to join both routes?
Reply
#2

(This post was last modified: 08-22-2022, 07:29 AM by SubrataJ.)

PHP Code:
app/Config/Routes.php
//.. Other routes

// Add this to Footer

// Including all module routes

$modules_path ROOTPATH 'Modules/';
$modules      scandir($modules_path);

foreach (
$modules as $module)
{
    if ($module === '.' || $module === '..')
    {
        continue;
    }

    if (is_dir($modules_path) . '/' $module)
    {
        $routes_path $modules_path $module '/Config/Routes.php';
  
        
if (file_exists($routes_path))
        {
            require $routes_path;
        }
        else
        {
            continue;
        }
    }



copied from @InsiteFX answer, this was working for me so suggesting ya too.
Learning Codeigniter 
Reply
#3

(08-22-2022, 07:29 AM)SubrataJ Wrote:
PHP Code:
app/Config/Routes.php
//.. Other routes

// Add this to Footer

// Including all module routes

$modules_path ROOTPATH 'Modules/';
$modules      scandir($modules_path);

foreach (
$modules as $module)
{
    if ($module === '.' || $module === '..')
    {
        continue;
    }

    if (is_dir($modules_path) . '/' $module)
    {
        $routes_path $modules_path $module '/Config/Routes.php';
  
        
if (file_exists($routes_path))
        {
            require $routes_path;
        }
        else
        {
            continue;
        }
    }



copied from @InsiteFX answer, this was working for me so suggesting ya too.
This is for loading routes from different modules it doesn't solve my issue.
Reply
#4

See https://viewi.net/docs/integrations
Reply
#5

I created CodeIgniter4 Viewi Demo:
https://github.com/kenjis/ci4-viewi-demo
Reply
#6

I've update the adapter:
https://github.com/kenjis/ci4-viewi-demo

And created another sample code for the Viewi's tutorial:
https://github.com/kenjis/ci4-viewi-tour-of-heroes
Reply
#7

CodeIgniter 4 Integration | Viewi
https://viewi.net/docs/integrations-code-igniter4
Reply




Theme © iAndrew 2016 - Forum software by © MyBB