codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.31k stars 1.89k forks source link

Bug: Cannot declare class Kint\Kint #8159

Closed pntrivedy closed 10 months ago

pntrivedy commented 10 months ago

PHP Version

8.2

CodeIgniter4 Version

4.4.3

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

macOS

Which server did you use?

apache

Database

MySQL

What happened?

I updated packages using 'composer update' faced this error.

Cannot declare class Kint\Kint, because the name is already in use

APPPATH/Config/Kint.php at line 41

namespace Kint;

use InvalidArgumentException;
use Kint\Parser\ConstructablePluginInterface;
use Kint\Parser\Parser;
use Kint\Parser\PluginInterface;
use Kint\Renderer\RendererInterface;
use Kint\Renderer\TextRenderer;
use Kint\Zval\Value;

/**
 * @psalm-consistent-constructor
 */
class Kint implements FacadeInterface
{
...

When I change env from development to production I face 404 error on route that was working fine previously.

Steps to Reproduce

Nil

Expected Output

Working app

Anything else?

No response

kenjis commented 10 months ago

From what version did you upgrade CI4? And did you follow all the upgrading guides? https://codeigniter4.github.io/CodeIgniter4/installation/upgrading.html

paulbalandan commented 10 months ago

Your file namespace is Kint?

pntrivedy commented 10 months ago

@kenjis : From 4.1.8

@paulbalandan : Yes namespace is Kint. Does App/Config/ have Kint.php by default?

paulbalandan commented 10 months ago

Why are you using Kint as your namespace?

kenjis commented 10 months ago

@pntrivedy I cannot reproduce the error. I've installed v4.1.8 and upgraded to v4.4.3. See https://github.com/kenjis/ci418to433/commits/main

pntrivedy commented 10 months ago

@paulbalandan : I haven't edited Kint.php. It was there in App/Config and while upgrading I have tried to replace it with Kint.php from sysytem/thirdparty/Kint/Kint.php

I think I have messed up at that point.

Let me try to get Kint from older commit and update AbstractRenderer.

paulbalandan commented 10 months ago

@pntrivedy Do not replace app/Config/Kint.php with the one inside system/ThirdParty/Kint/Kint.php! They are different classes.

kenjis commented 10 months ago

app/Config/Kint.php is a Config class for CI4. Copy the latest one. https://github.com/kenjis/ci418to433/blob/main/app/Config/Kint.php