zend framework 2 fatal error after add module - php

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 :-/

Related

PHP7 Type error with interface

In my symfony project I got an error with a vendor.
Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 passed to eZ\Publish\Core\MVC\Legacy\Kernel\Loader::setCLIHandler() must implement interface ezpKernelHandler, instance of eZ\Publish\Core\MVC\Legacy\Kernel\CLIHandler given, called in /Users/steve/Projects/Web/BuildSuccess/www/vendor/ezsystems/legacy-bridge/mvc/Kernel/Loader.php on line 237 in /Users/steve/Projects/Web/BuildSuccess/www/vendor/ezsystems/legacy-bridge/mvc/Kernel/Loader.php:255
But this error is strange because I checked and eZ\Publish\Core\MVC\Legacy\Kernel\CLIHandler implements the interface ezpKernelHandler !
namespace eZ\Publish\Core\MVC\Legacy\Kernel;
use ezpKernelHandler;
class CLIHandler implements ezpKernelHandler
{
...
}
I tried to debug, with get_class method and I get
"eZ\Publish\Core\MVC\Legacy\Kernel\CLIHandler"
I also used class_implements method and I get
array(0) {
}
Any idea what append ?
Thanks
I see that it is not your code, but rather eZ Publish itself. Because of this it is unlikely that you will be able to update sources, but there is still some things that you can do:
Check your Composer autoloader configuration to see that ezpKernelHandler class is properly resolved. You may need to register custom autoloader for it.
You're most likely receiving this error because you're using Symfony 3.3+ and its recently added services auto-configuration features. You can avoid this error to be thrown by disabling service auto-configuration for affected service, take a look at example here
Since this error is fatal but catchable - if nothing else will help you can create your own service factory for this particular service and catch error inside it.
Fixed : https://github.com/ezsystems/LegacyBridge/issues/132
It is easilly fixed by creating app/autoload.php file which requires both vendor/autoload.php and ezpublish_legacy/autoload.php and changing bin/console to require that file instead of vendor/autoload.php

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 CodeIgniter Generate Fixtures PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found

So have PHPUnit and CodeIgniter installed:
http://d.hatena.ne.jp/Kenji_s/20120117/1326763908
Couldn't download the PEAR as its been deprecated. So had to download the phpunit phar file:
http://phpunit.de/manual/4.0/en/installation.html#installation.phar
So was able to get some tests to run properly. Moved my phpunit.phar to /usr/local/bin and ran on the tests dir:
php /usr/local/bin/phpunit.phar
And all the tests ran correctly. But when i tried to run the php generate fixtures and php generate.php fixtures:
PHP Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /www/test/application/third_party/CIUnit/libraries/CIUnitTestCase.php on line 15
Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /www/test/application/third_party/CIUnit/libraries/CIUnitTestCase.php on line 15
Seems like its not finding the classes inside the phar file or at least they are not in the correct order? What is funny is that it runs the tests fine but not the generate fixtures.
Additionally i also installed using composer the phpunit so i have a /www/test/vendor/bin/phpunit installed as well.
Any help would be appreciated.
I had the same problem in my code, although I do not use the CodeIgniter. Trying to run tests would result in the error message:
Class 'PHPUnit_Framework_TestCase' not found
For what it's worth I had this fixed by adding a backslash to my test class declaration.
// Before
namespace IMAVendor\Super\Duper;
class MyClassTest extends PHPUnit_Framework_TestCase
// After
namespace IMAVendor\Super\Duper;
class MyClassTest extends \PHPUnit_Framework_TestCase
^
Added this backslash here
This seems to have something to do with namespaces and the autoloader that's built in phpunit. I have my own autoloader for the project code and it seems that it was trying to load the phpunit's classes from my code. I'm not really sure why it didn't try to load it from the 'base' when it wasn't able to find it in the projects namespace (This may very well be due to my own autoloader being faulty).
I know this is an old question, but I'll just leave this here in case it may help somebody somewhere.

libphonenumber php cannot find base class Locale

I am using the php implmentation of libphonenumber from
giggsey/libphonenumber-for-php
I need it to just do a basic sense and validity check on a phone number entered by a users.
I have taken the whole src/libphonenumber directory and its sub directories and copied it into my project. I do not use Composer and, as this is only one element of my project, am hoping not to have to climb that particular learning curve just now. I put the following simple autoloader at the start of the script.
namespace libphonenumber;
spl_autoload_register('libphonenumber\myAutoloader');
function myAutoloader($className)
{
$path = 'libphonenumber/';
$parts=explode('\\',$className,2);
$filename=str_replace('\\','/',$parts[1]);
include $path.$filename.'.php';
}
The auto loader works fine except for when it comes to include the file geocoding/Locale.php which includes a single class 'Locale' as follows;
class Locale extends \Locale
The error I get is
PHP Fatal error: Class 'Locale' not found in /var/www/luthor/php/libphonenumber/geocoding/Locale.php on line 6
I am pretty new to namespaces and oo in php. I understand that Locale is a php class. My question is Why is it not found
Found the answer. The use of Locale requires the international extension for php to be installed see the following question
Fatal error: Class 'Locale' not found with ZF2 beta5 skeleton application

SoapClient class missing

I need to use SoapClient class. Once I run a script that use it I get the following error:Fatal error: Class 'SoapClient' not found in /home/example/public_html/affiliate_script/acquireFeeds.php on line 11
I have already asked my client to install it but he says it is impossible so far. Do you know any class that could be equivalent to the SoapClient and can be downloaded?
You could try NuSOAP which is a PHP-only solution that requires no extensions to be present (besides XML handling extensions I suppose).

Categories