Class 'Magento\Framework\App\Action\Action' not found - php

I'm running Magento v2.2.2 on MAMP (PHP 7.0.33), and am trying to debug a third party module that deals with tracking numbers.
The full error that shows in my MAMP/logs/php_error.log when I try to run the module is as follows:
PHP Fatal error: Class 'Magento\Framework\App\Action\Action' not found in /Applications/MAMP/htdocs/magento/app/code/Orderinfo/Details/Controller/Index/index.php on line 20
PHP Stack trace:
PHP 1. {main}() /Applications/MAMP/htdocs/magento/app/code/Orderinfo/Details/Controller/Index/index.php:0
Here is what Applications/MAMP/htdocs/magento/app/code/Orderinfo/Details/Controller/Index/index.php looks like:
namespace Orderinfo\Details\Controller\Index;
use Magento\Framework\Controller\ResultFactory;
class Index extends \Magento\Framework\App\Action\Action {
protected $_productloader;
protected $_messageManager;
protected $_pageFactory;
public function __construct...(and so forth)
The weird thing is, the command setup:di:compile runs just fine (it also fails to compile as expected when I modify the above line to say something like class Index extends \Bogus\Magento\Framework\App\Action\Action.)
I've confirmed that the Framework/App/Action/Action.php file/class exists in magento/lib/internal/Magento, magento/vendor/magento, and magento/app/code/Magento. I also modified the .htacess of those directories to grant all access.
I'm pretty lost, if anyone has ever encountered this problem before and could give me some other things to try, that'd be awesome.
Thank you!

Related

Travis cannot find 'PHPUnit_Framework_TestCase' – sometimes

I've just started using Travis CI to test my PHP code. Sometimes, builds fail with the message
PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /home/travis/build/ms609/citation-bot/tests/phpunit/expandFnsTest.php on line 13
On other occasions, without my having changed any relevant code, the builds succeed.
This makes me suspect that the issue is at Travis's end rather than my own.
This makes me wonder: is there anything that I can do to reduce the likelihood of my encountering this error? And on builds when the error arises, is it possible to have Travis re-attempt the build without making a new commit?
I had inherited a testcase written using an older version of phpunit. For backwards compatibility, following advice elsewhere, I had added the code
if (!class_exists('\PHPUnit\Framework\TestCase') &&
class_exists('\PHPUnit_Framework_TestCase')) {
class_alias('\PHPUnit_Framework_TestCase', 'PHPUnit\Framework\TestCase');
}
What I needed to do next was replace
class myTest extends PHPUnit_Framework_TestCase {
with
class myTest extends PHPUnit\Framework\TestCase {
With regards to the second part of the question, signing in to Travis CI reveals a "restart build" option on the build page.

CakePHP 1.3 Shell can't find AppModel class

I'm migrating a CakePHP 1.3 app from an old server to a new one, the website works fine but the Shells fail with the following error:
PHP Fatal error: Class 'AppModel' not found
And the error points to the declaration of a model that extends from the AppModel class. It also somewhat strangely prints the contents of the AppModel class to stdout. Full stack trace below.
PHP Fatal error: Class 'AppModel' not found in /home/andyburchill/src/site/app/models/account.php on line 3
PHP Stack trace:
PHP 1. {main}() /home/andyburchill/src/site/cake/console/cake.php:0
PHP 2. ShellDispatcher->ShellDispatcher() /home/andyburchill/src/site/cake/console/cake.php:665
PHP 3. ShellDispatcher->dispatch() /home/andyburchill/src/site/cake/console/cake.php:139
PHP 4. Shell->initialize() /home/andyburchill/src/site/cake/console/cake.php:337
PHP 5. Shell->_loadModels() /home/andyburchill/src/site/cake/console/libs/shell.php:180
PHP 6. ClassRegistry->init() /home/andyburchill/src/site/cake/console/libs/shell.php:257
PHP 7. App->import() /home/andyburchill/src/site/cake/libs/class_registry.php:143
PHP 8. App->__find() /home/andyburchill/src/site/cake/libs/configure.php:962
PHP 9. App->__load() /home/andyburchill/src/site/cake/libs/configure.php:1043
PHP 10. require() /home/andyburchill/src/site/cake/libs/configure.php:1067
I'm running the shell from the root directory with the following command:
./cake/console/cake queue
The most notable difference between the servers is the PHP version, the shells are working on PHP 5.4.9 and are not working on PHP 5.5.9.
I have been googling this for a couple of days, usually people seem to get this error after upgrading to CakePHP 2.x and the fixes don't work for CakePHP 1.3.
I'm beginning to think the only solution is going to be upgrading to 2.x, but this is not a trivial task.
Is there something I can do in the mean time to get this working?, can anyone suggest troubleshooting tips?.
Ok I feel a bit silly now.
I had tried Raphael's suggestion of requiring the class file previously but I decided to try again and noticed that the AppModel class file started with a short open tag instead of <?php.
After changing it the shells now work.

PHPUnit does not work with IntelliJ Idea 13.1.3

I get the following exception while using Idea 13.1.3 with PHPUnit 4.5.0. In some other threads I have seen it was a bug but I this seems to be a problem with latest version also.
Testing started at 17:06 ...
Fatal error: Class IDE_PHPUnit_Framework_TestListener contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (PHPUnit_Framework_TestListener::addRiskyTest) in /private/var/folders/yc/cc0z8db95hx4l_d0fvtrx2yxsjjh3x/T/ide-phpunit.php on line 504
Call Stack:
0.0014 854704 1. {main}() /private/var/folders/yc/cc0z8db95hx4l_d0fvtrx2yxsjjh3x/T/ide-phpunit.php:0
Variables in local scope (#1):
$PHPUnitVersionId = *uninitialized*
Process finished with exit code 255
Found from IntelliJ forum that IntelliJ 13 is only compatible with PHPUnit 3.x.
However instead of downgrading, I managed to patch the framework itself for now in this way.
go to /plugins/php/lib
make a backup of php.jar
Use whatever tool you have to open the file, usually zip or other compress tools or under ubuntu the file roller.
Go to scripts/phpunit.php
Modify it, searching for the "IDE_PHPUnit_Framework_TestListener" class and adding there the following line:
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception
$e, $time) {}
save the file and update the php.jar

zend framework 2 fatal error after add module

I install ZF2 on my localhost and then I test the public page and it is work.
I tried to download a module MwopGuestbook and then zend show me an error:
Fatal error: Interface 'Zend\Module\Consumer\AutoloaderProvider' not
found in D:\xampp\htdocs\zend\module\MwopGuestbook\Module.php on line 8
How can we solve this problem?
Looks like outdated code there, I'm guessing that's an early incarnation of the Zend\ModuleManager\Feature\* implementations
If it is, you can try changing the first 7 lines in MwopGuestbook/Module.php to the following...
<?php
namespace MwopGuestbook;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
class Module implements AutoloaderProviderInterface
{
It should solve the complaints about not finding the interface, no guarantees there aren't other parts of that code using outdated calls though :-/

PHP Class resolve issue for classes in the same directory when running PHPUnit test cases

I installed PHPUnit and my Test class looks like this:
require_once 'PHPUnit/Framework/TestCase.php';
class Test extends PHPUnit_Framework_TestCase {...}
When I execute the PHP script in Eclipse, I get the following error:
Fatal error: Class 'PHPUnit_Framework_Assert' not found in .../PEAR/PHPUnit/Framework/TestCase.php on line 99
So I created a general PHP classloading test:
A.php and B.php in the same directory
A.php:
class AA {}
B.php:
class BB extends AA {}
new BB();
When executing the PHP script B.php I get the same error:
Fatal error: Class 'AA' not found in .../B.php on line 2
There must be an option for PHP to be able to resolve these classes otherwise PHPUnit could not work. Any ideas?
Thank you.
You should not be loading / require
require_once 'PHPUnit/Framework/TestCase.php';
in your tests at all. The normal phpunit runner should be able to figure that out.
Usually IDEs should care about setting phpunit up properly (or invoking it properly) but if that doesn't work out requiring
require_once 'PHPUnit/Autoload.php';
That should do the trick then as this is whats needed to make PHPUnit working
I ran into this issue when integrating with NetBeans. The solution for me was to load a bootstrap.php file, which would include all necessary dependencies while leaving my class files untouched.
Oops: just realized you're using Eclipse. It should be pretty similar. The problem is likely that your include script is relative to Eclipse's working directory (or some directory other than where you application normally runs). But that's a stab in the dark without being too familiar with Eclipse myself...
In case PHPUnit 6.x is used, then PHPUnit_Framework_Assert class has been removed. You should use namespaces instead, or downgrade to ~4.5.
So replace PHPUnit_Framework_Assert with \PHPUnit\Framework\Assert, ot use statement like:
use PHPUnit\Framework\Assert;
And use Assert directly, e.g. Assert::assertNotEmpty(...);.
Source: Class 'PHPUnit_Framework_Assert' not found (Behat\Testwork\Call\Exception\FatalThrowableError #2585

Categories