[BETA] Fatal error: Cannot use Joomla\Utilities\ArrayHelper as ArrayHelper #1061
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: joomla/Component-Builder#1061
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Steps to reproduce the issue
Create any component
Compile the component
Install the component
Try to access the component from the admin menu.
Expected result
To see the Dashboard of the component
Actual result
Fatal error: Cannot use Joomla\Utilities\ArrayHelper as ArrayHelper because the name is already in use in C:\wamp64\www\j3dev\administrator\components\com_test\controller.php on line 27
System information (as much as possible)
Additional comments
the beginning of the content of controller.php
I am not trying to make excuses, but until now I have not tried to understand the Powers.
Is this a suitable solution?
In CJB I went to Powers, edited Utilities Array Helper and changed its name from: ArrayHelper to VdmArrayHelper.
And I also changed the Namespace from
VDM\Joomla\Utilities.ArrayHelper to VDM\Joomla\Utilities.VdmArrayHelper
And now it sims to work, but there is still a problem
use VDM\Joomla\Utilities\VdmArrayHelper;
is not added to the view file default_vdm.phpAnd also I know that nothing should be above
defined('_JEXEC') or die('Restricted access');
This is a Joomla 3 path right?
In JCB, I navigated to Powers, edited the Utilities Array Helper, and renamed it from
ArrayHelper
toVdmArrayHelper
.This is a significant modification, and making such changes without a thorough understanding of how powers operate is risky 😉
The PHP version is currently 7.4.33. Please upgrade to at least PHP version 8.0.0. I have been using PHP 7 for quite some time and wouldn't be surprised if things malfunction or break on that older version.
When examining this controller template, as well as an extension where this file is constructed, everything appears to be correct and is being built as anticipated. This suggests that upgrading your PHP version might resolve the issue.
It's worth noting that JCB itself is constructed using JCB. Thus, the fact that JCB operates smoothly (in the beta branch for Joomla 3.10) is evidence that it's being built correctly most of the time. In fact, all my work is in the beta branch, meaning all my activities and the projects I manage. If the beta branch causes any issues with my projects, I typically notice and rectify them well before releasing the next update.
We have a class that searches the template (data) to identify where to insert the additional namespaces found in the listed powers, such as the
Super___1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check($ref)
value. This class can be observed here, attempting to find the insertion point. If unsuccessful, it places the newuse
statements below thedefined
statement. This seems to be the case with your file. This issue likely arose from the need to adjust the regex 'preg_match($pattern, $code, $matches, PREG_OFFSET_CAPTURE);' when transitioning from PHP 7.4 to 8.0+. This explanation delves deeper into our method of adding the powers header (use statements) to the file. This step occurs towards the end of the compiler process, yet sufficiently early to include the file in the package.The power feature in JCB is incredibly powerful, and it has become my primary tool. It allows for the full integration of PHP with JCB and Joomla. I believe it has resolved a significant challenge for developers, a problem many are not yet aware of. Hence, I understand if you and others haven't taken much interest in the powers feature. However, as your extensions in JCB become more advanced and valuable, you'll find yourself using powers more frequently—it represents the future. Although there are a few tutorials available, I admit I haven't kept everyone fully informed about its progress. Its features are particularly relevant to those managing large-scale JCB projects with around 500k lines of code, integrating with multiple external systems, and surpassing JCB's complexity.
I've begun developing a script that will enable the capturing of powers from various power repositories into a composer package for distribution via the "composer" channel, aiming to bridge our applications across different CMS and framework barriers. The sooner you master the "power" capabilities of JCB, the more remarkable applications you'll be able to create.
C:\wamp64\www\j3dev\administrator\components\com_test\controller.php
Yes sir, this is a Joomla 3 path.
I was trying to test my component on the same !J3 website, where JCB is installed, to avoid to move back and forward between J3 and J4 😅
Regarding the PHP version (8.0.30), nothing is changing on joomla 3, same problem as before.
I see that the component works if I compile it for !J4&5, but there is still the problem with the missing code
use VDM\Joomla\Utilities\ArrayHelper;
, is not added to the view file default_vdm.php, witch is the view for Dashboard.But I can access the other views from admin if the view is set to show in the main menu.
So all of this was the situation on my local server using:
wamp v3.3.2, PHP v8.0.30, Apache v2.4.58, Maria v11.2.2, phpMyAdmin v5.2.1 MySQL 8.2.0
==========================================================================================
I said I'd do some more digging before I post again.
I made a clone of the whole site from the local server and put it on a real server, everything seems to be ok.
I wonder what is causing the problem on my local server?
On the "real server" I even use php 7.4.33 and is still working right...
This is the preferred way to run JCB (in docker) https://www.youtube.com/watch?v=owpxKie0I7s
So we can be sure we are in the same environment "more or less", this is also how I work... only on Ubuntu, and only in Docker.
Thank you, after 1 day I managed to Install VirtualBox + Ubuntu and to set the environment following the tutorial from your video, it took me a while but I did it.
It was not a problem to install VirtualBox + Ubuntu and to do what you do in that tutorial, the sad part was after, when I was trying to access the "octoleo.joomla.vdm", or the "port.joomla.vdm", it was not working.
I'm not going to start telling everything, but I think the problem is from "octojoom > Traefik Container", after trying to set it (the first run), I was getting errors like this:
WARN[0007] a network with name traefik_webgateway exists but was not created by compose. Set 'external: true' to use an existing network network traefik_webgateway was found but has incorrect label com.docker.compose.network set to ""
This was my first time trying to use docker, and I installed ubuntu just out of curiosity, a long time ago
In "Docker/traefik", I have edited "docker-compose.yml", and I've changed the code starting with line 37.
DEFAULT
EDITED
Thank you, I will close this Issue.
You can bump (open an issue) the octojoom repo directly ;)
So yesterday our in house testing Team found that they could not get a few of our own components to work, it kept missing classes. We then discovered that the installer of Joomla times-out and the complete package does not install, even thought it says that it did. So they asked me what tweaks to PHP I am using on my development system. So here is some of my PHP.ini tweaks:
If you add these, and install JCB again.... and also on the system where your planning to install you component... I think it will resolve your problem. Yes, you could remove this in most cases after the install, but in your development system it might be best to keep it on.
But for large extensions like those that JCB can build making these changes seems necessary, at least on the initial install.