kenjis / codeigniter-ss-twig

A Simple and Secure Twig integration for CodeIgniter 3.x and 4.x
MIT License
168 stars 46 forks source link

Class 'Kenjis\CI4Twig\Twig' not found in CI4 #67

Closed adamcaz closed 11 months ago

adamcaz commented 1 year ago

Hi Kenjis, I've used this fantastic project before in a CI3 project.

However i'm trying to use it in a new CI4 project and i'm getting the following error: "Class 'Kenjis\CI4Twig\Twig' not found"

I've installed via Composer and everything is sitting in my vendor folder ready to go.

I'm using the following code in my CI4 controller which is generating the error:

$twig = new \Kenjis\CI4Twig\Twig();
$render = $twig->render($templatename, $templatedata);

Any ideas what i'm doing wrong?!? Thanks in advance!

kenjis commented 1 year ago

I cannot reproduce.

$ composer create-project codeigniter4/appstarter ci440
$ cd ci440/
$ composer require kenjis/codeigniter-ss-twig
$ echo "Hello World!" > app/Views/welcome.html.twig
<?php

namespace App\Controllers;

class Home extends BaseController
{
    public function index(): string
    {
        $twig = new \Kenjis\CI4Twig\Twig();

        return $twig->render('welcome.html', []);
    }
}

Navigate to http://localhost:8080/, I see "Hello World!".