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
#8

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?
Reply
#9

https://github.com/lonnieezell/cellular

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

(This post was last modified: 08-27-2023, 09:14 PM by murugappan.)

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




Theme © iAndrew 2016 - Forum software by © MyBB