CodeIgniter Forums
Using Viewi and CI4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Using Viewi and CI4 (/showthread.php?tid=82774)

Pages: 1 2


Using Viewi and CI4 - vimkaf - 08-22-2022

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?


RE: Using Viewi and CI4 - SubrataJ - 08-22-2022

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.


RE: Using Viewi and CI4 - vimkaf - 08-22-2022

(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.


RE: Using Viewi and CI4 - kenjis - 08-23-2022

See https://viewi.net/docs/integrations


RE: Using Viewi and CI4 - kenjis - 10-14-2022

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


RE: Using Viewi and CI4 - kenjis - 10-17-2022

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


RE: Using Viewi and CI4 - kenjis - 10-25-2022

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


RE: Using Viewi and CI4 - murugappan - 08-26-2023

Hi,
I was looking for an integration of Laravel Livewire into CI4 and then i found "Viewi". I was so excited that we could do the same with CI4. Then came the damper to my excitement. I went through @kenjis 's documentation on Viewi integration and realized i, being not a high techie, had to do underhood hacking to do get this working. Especially when taking about the Response class.
This para instantly knocked my off my chair "By default, Response object keeps data as a string (html or json encoded). But you need to pass an original data, for example, if your API returns a BlogPostModel, you do not want to receive a json object instead of a fully typed instance of BlogPostModel class." Going further down the documentation it got worse. I realised it was not so straight forward.
All i want, as a business developer using CI4, are to Install the Viewi and use the features in delivering the contents and reactively update page components very similar to Vuejs.
Is there such a thing, please?


RE: Using Viewi and CI4 - datamweb - 08-27-2023

https://github.com/lonnieezell/cellular

This was also a good thing, but I don't think it is usable at this stage.


RE: Using Viewi and CI4 - murugappan - 08-27-2023

(08-27-2023, 12:33 AM)datamweb Wrote: https://github.com/lonnieezell/cellular

This was also a good thing, but I don't think it is usable at this stage.

Unfortunate, the creators appears to have gone dormant too.