error: class not found

For Joomla! 4.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
User avatar
JurajB
Joomla! Guru
Joomla! Guru
Posts: 642
Joined: Fri Oct 02, 2015 3:28 pm

error: class not found

Post by JurajB » Sat Jul 23, 2022 10:39 am

Hello!
I got this:
Class "IrcChatNamespace\Component\IrcChat\Administrator\Extension\IrcChatComponent" not found

Here is this in my files:
in com_ircchat\ircchat.xml:

Code: Select all

<namespace path="src">IrcChatNamespace\Component\Ircchat</namespace>

in com_ircchat\services\provider.php:

Code: Select all

use IrcChatNamespace\Component\IrcChat\Administrator\Extension\[b]IrcChatComponent[/b];
and

Code: Select all

        $container->set(ComponentInterface::class, function(Container $container)
        {
            $component = new [b]IrcChatComponent[/b]($container->get(ComponentDispatcherFactoryInterface::class));
            $component->setRegistry($container->get(Registry::class));
            return $component;
        }
Am I missing something?


And here is com_ircchat\src\extension\IrcChatComponent.php:

Code: Select all

class [b]IrcChatComponent[/b] extends MVCComponent implements BootableExtensionInterface, CategoryServiceInterface
{
    use CategoriesServiceTrait;
    use HTMLRegistryAwareTrait;

    public function boot(ContainerInterface $container)
    {
        $this->getRegistry()->register('irchatadministrator', new AdministratorService);
    }
}

MarkRS
Joomla! Explorer
Joomla! Explorer
Posts: 329
Joined: Thu Oct 29, 2009 8:28 am
Location: UK

Re: error: class not found

Post by MarkRS » Sat Jul 23, 2022 2:22 pm

There's nothing (very) obviously wrong (I think).

What you haven't said is where and when you get the error. That would help. :eek:
It's a community, the more we all contribute, the better it will be.

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2908
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: error: class not found

Post by SharkyKZ » Sat Jul 23, 2022 2:23 pm

Class names are case sensitive in this case. And file names must match class names exactly.

User avatar
JurajB
Joomla! Guru
Joomla! Guru
Posts: 642
Joined: Fri Oct 02, 2015 3:28 pm

Re: error: class not found

Post by JurajB » Sat Jul 23, 2022 2:41 pm

still not working
its in the administrator > components > com_ircchat (name of component) when I click on it there should be hello ircchat but instead there is this error msg

MarkRS
Joomla! Explorer
Joomla! Explorer
Posts: 329
Joined: Thu Oct 29, 2009 8:28 am
Location: UK

Re: error: class not found

Post by MarkRS » Sat Jul 23, 2022 4:20 pm

What have you got in your component xml file for administrator menus?
Do you have a DisplayController for the component?

It seems you've got something in the xml file that creates a component menu in your admin panel (do you?) so, if that's the case you've got something, but it's not calling the right thing, or your controller doesn't "use" the correct namespace.

That's my initial guess(es) anyway.

I still (always) say create a local installation, step through your code, find the exact problem (more) quickly.
It's a community, the more we all contribute, the better it will be.

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2908
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: error: class not found

Post by SharkyKZ » Sat Jul 23, 2022 6:24 pm

JurajB wrote:
Sat Jul 23, 2022 2:41 pm
still not working
its in the administrator > components > com_ircchat (name of component) when I click on it there should be hello ircchat but instead there is this error msg
Have you fixed class and file casing?

User avatar
ceford
Joomla! Hero
Joomla! Hero
Posts: 2677
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: error: class not found

Post by ceford » Sat Jul 23, 2022 8:56 pm

JurajB wrote:
Sat Jul 23, 2022 10:39 am
I got this:
Class "IrcChatNamespace\Component\IrcChat\Administrator\Extension\IrcChatComponent" not found

Code: Select all

<namespace path="src">IrcChatNamespace\Component\Ircchat</namespace>
In your code, try changing all instances of IrcChat to Ircchat.

You may have other problems too. See https://docs.joomla.org/J4.x:Links:_MVC_Anatomy for some code you can look at.

In Global Configuration set Debug System to Yes and Error Reporting to Maximum. The stack trace should indicate where the error was triggered (which file and line).

User avatar
JurajB
Joomla! Guru
Joomla! Guru
Posts: 642
Joined: Fri Oct 02, 2015 3:28 pm

Re: error: class not found

Post by JurajB » Sun Jul 24, 2022 12:16 pm

Hi!
fixed a typo now I got this:

Sorry, there was a problem we could not recover from.

The server returned a "500 - Whoops, looks like something went wrong."

MarkRS
Joomla! Explorer
Joomla! Explorer
Posts: 329
Joined: Thu Oct 29, 2009 8:28 am
Location: UK

Re: error: class not found

Post by MarkRS » Sun Jul 24, 2022 1:54 pm

When did you "get this"? Making a cup of tea?

Although you've given us what you got, without knowing what you were doing it's really hard to help.
It's a community, the more we all contribute, the better it will be.


Locked

Return to “Joomla! 4.x Coding”