Zend Framework 2 error - php

After a composer update my application don't run anymore.
The error is:
PHP Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\InvalidArgumentException' with message 'Provided abstract factory must be the class name of an abstract factory or an instance of an AbstractFactoryInterface.' in /path_to_app/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:302
I googled the error and seems that in may 2013 happened something similar that could be solved just commenting two lines in the module.config.php
Naturally, I've tried that but it doesn't seem to work.
Any ideas?

You have a factory service configuration issue in your module.config.php, like the error says one of your configured factory services is not a "class name of an abstract factory or an instance of an AbstractFactoryInterface.".
For debugging purpose, try to temporarily disable your application registered modules one by one to detect in which module this is configured (if you have no idea), until the error disappear.
Then check the services configs.

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

'Twig_Error_Syntax' with message 'Unknown "render" filter

I'm running drupal 8, composer and npm to perform gulp tasks.
When I run npm start.. my task manager: I get the following stack trace:
Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'Unknown "render" filter.' in /web/project/web/themes/emulsify/components/_patterns/04-templates/basic-page/_basic_page.twig:26
Stack trace:
#0 /web/project/web/themes/emulsify/pattern-lab/vendor/twig/twig/lib/Twig/ExpressionParser.php(481): Twig_ExpressionParser->getFilterNodeClass('render', 26)
#1 /web/project/web/themes/project_theme/pattern-lab/vendor/twig/twig/lib/Twig/ExpressionParser.php(466): Twig_ExpressionParser->parseFilterExpressionRaw(Object(Twig_Node_Expression_Name))
#2 /web/project/web/themes/project_theme/pattern-lab/vendor/twig/twig/lib/Twig/ExpressionParser.php(320): Twig_ExpressionParser->parseFilterExpression(Object(Twig_Node_Expression_Name))
#3 /web/project/web/themes/project_theme/pattern-lab/vendor/twig/twig/lib/Twig/ExpressionParser.php(212): Twig_ExpressionParser->parsePostfixExpression(Object(Twig_Node_Expression_Name))
#4 /web/project in /web/project/web/themes/project_theme/components/_patterns/04-templates/basic-page/_basic_page.twig on line 26
I've looked at installing twig-bridge / symfony twig via composer but I can't seem to get rid of the error message.
Do I just ditch using the twig filter "render"?
Update: 14/08/17
I've also ran into the same problem when trying to use the drupal_block function provided via Drupal 8's twig_tweak module.
The problem in the code above is that your Twig extension class is extending the internal Drupal Twig extension class. That breaks the Twig extensions added by Drupal core and that's why you are getting the error.
To fix this, you should make your Twig extensions extend Twigs internal Twig extension class. Your class should be defined like this:
class MyExtension extends \Twig_Extension {
After making that change, you can also remove arguments set for that class from the MODULE.services.yml
link
I've not seen this in the Drupal context, but working with other platforms that use Twig, I have seen similar issues occurring when an error occurs early in the platform setup process.
The typical sequence of events is like this:
The platform starts running its bootup; loading the CMS core, etc.
At some point early in this process, it hits an error.
It then tries to render an error page.
However, the error page uses a Twig template.
The startup process has not yet loaded all the twig extensions used in the template.
Boom, you get a twig error stating "unknown Twig function" instead of the real error message.
When I've had this before, it has proved very hard to diagnose what the actual error is.
The "correct" solution has been to modify the error page templates so that they are minimal and don't use any non-core twig functions. But if you're getting a crash early in the page load process it can be hard to actually do that.
In the first case, I resolved it by debugging the system and trapping what data was passed to the template. This showed me what the real error was. Resolving that error then stopped the twig error from occurring and allowed me to get into the system.
I don't know for sure if what you're seeing is the same kind of thing as what I was seeing, but it sounds similar so I hope this will help.

Symfony2 - Class XXX not found

I have deployed a Symfony Application to a one.com server. I wrote a Mail service that sends my emails via SwiftMailer.
Now, since one.com has no phar-extensions allowed, composer cannot be updated via ssh. So I generated the classmap locally with
composer update -o
Whenever I try to get the Mail service, the application throws an error:
Fatal error: Class
'Stocksolutions\ShopBundle\DependencyInjection\Mail' not found in
/customers/4/b/b/stocksolutions.be/httpd.www/releases/20150204201140/app/cache/dev/appDevDebugProjectContainer.php
on line 3602
I have searched the composer classmap and the class that isn't found is inside it:
'StockSolutions\\ShopBundle\\DependencyInjection\\Mail' => $baseDir . '/src/StockSolutions/ShopBundle/DependencyInjection/Mail.php'
Furthermore, I can get other services in the container, f.e. those from the FOSUserBundle, but getting my custom services throws an error. Also, I don't get these errors when testing locally..
Any ideas?
It's case-sensitive problem.
Your error:
Fatal error: Class
'Stocksolutions\ShopBundle\DependencyInjection\Mail' not found
Small letter s in Stocksolutions namespace for PSR forces to search for the file /src/Stock**s**olutions/ShopBundle/DependencyInjection/Mail.php, but exist /src/Stock**S**olutions/ShopBundle/DependencyInjection/Mail.php.
On local system likely Windows, where the path/filenames case-insensitive, error does not occur.
P.S. Most likely a typo in class namespace is in the bundle service description (services.yml/services.xml).

Guzzle annotations not working with Doctrine2 annotation parser in Symfony2 project

I've got a Symfony2 project and am trying to integrate the GuzzleBundle to build a web service client. I'm using the #guzzle annotations for the client commands (which extend Guzzle\Service\Command\AbstractCommand).
It seems to work correctly in the dev environment but when I try to load pages using the prod environment I get a Doctrine AnnotationException:
PHP Fatal error: Uncaught exception 'Doctrine\Common\Annotations\AnnotationException' with message '[Semantical Error] The annotation "#guzzle" in class Admin\FindAnExpertBundle\Entity\SymplecticClient\Rest\Command\UserById was never imported. Did you maybe forget to add a "use" statement for this annotation?'
I also get an error about a missing Proxy class file:
PHP Warning: require(/home/httpd/sites/experts.admin/app/cache/prod/doctrine/orm/Proxies/AdminFindAnExpertBundleEntityRelationshipTypeProxy.php) [<a href='function.require'>function.require</a>]: failed to open stream: No such file or directory in /home/httpd/sites/experts.admin/vendor/doctrine/lib/Doctrine/ORM/Proxy/ProxyFactory.php
I assume this is because the fatal error is stopping all the proxy classes from being created.
Guzzle appears not to use the Doctrine annotation parser so I'm wondering if there's a way to make it ignore #guzzle annotations or register them somehow?
You have to import the annotation-Parser of Guzzle, which handles the "#guzzle" annotation, e.g.:
use Guzzle\Service\Inspector as guzzle;
But i don't know which class it is.
Maybe this gist file helps you.
I ended up moving the classes relating to the web service client out of the Entity folder, which stopped the Doctrine annotation parser from reading them. In retrospect, the classes shouldn't have been in that folder anyway.

FOSUserBundle installation error

Edited: [solved!!]
Oops... typo in the class. My mistake. Solved!
End of edition
I am new in Symfony. I have installed Symfony 2.0.12.
I am trying to install FOSUserBundle just to see how it works.
I think I have followed all the steps detailed in the installation documentation.
I have an Acme/StoreBundle/Entity/User.php that extends the UserBase class in the FOSUserBundle "FOS/UserBundle/Entity/User". I am doing it exactly as said in the documentation.
When I run the demo, I am getting the following error:
Fatal error: Cannot redeclare class User in
/Users/pgbonino/Sites/Symfony/src/Acme/StoreBundle/Entity/User.php on
line 12
No matter how I name my User class, that I always get the corresponding error. The first idea was to change the name of the class to "myUser" (so it would be "class myUser extends BaseUser". But then the error changes to:
cannot redeclare class myUser
So strange.
Anyone any idea?
It sounds as if I were declaring the User class somewhere else. And in fact, it is declared in the FOSUserBundle and in my AcmeStoreBundle. But, unless I am loosing something, that is what the documentation says to do.

Categories