FOSUserBundle installation error - php

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.

Related

Getting error that actually not an error in vscode while using intelephense

Getting unexpected error (Expected 1 arguments. Found 0) in vscode while using intelephense extension.
When I uninstall the intelephense extesion from vscode at that time this error not showing but i dont want to uninstall the extension.
how can i solve this issue??
Error starts showing when i write __construct method in (2.php) file.
Error:
Use namespaces as Brombeer suggests in the comment he made to your question, he deserves credit for this.
I define it based off of the class that the file contains, so I have a class named Animal, and keep the namespace within the Animal class:
<?php
namespace Animal;
class Animal ...
The error exists because the IDE thinks the class you're extending exists as it's using the global namespace
why it's in the global namespace:
https://www.php.net/manual/en/language.namespaces.global.php
namespaces:
https://www.php.net/manual/en/language.namespaces.definition.php
edit: forgetting to add code blocks to comment...

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

Symfony2 Can't inherit abstract function Validator\ValidatorInterface::validate() (previously declared abstract in \Validator\ValidatorInterface)

If I use the symfony console command generate:doctrine:crud with --write parameter I get an auto-generated controller working only in the indexAction route, but not in the others (newAction, deleteAction, updateAction). I think the problem is in the form creation.
The resulting error is the following one:
Compile Error: Can't inherit abstract function
Symfony\Component\Validator\ValidatorInterface::validate() (previously
declared abstract in
Symfony\Component\Validator\Validator\ValidatorInterface)
Server Error - FatalErrorException500 Internal in vendor/symfony/symfony/src/Symfony/Component/Validator/Validator/RecursiveValidator.php at line 31
I don't know, how to solve this problem.
This error is the error message you get when running the new validator component in PHP 5.3.8 or older. You need to use at least PHP 5.3.9 to use recent versions of Symfony
The only way to solve this problem is to change ValidatorInterface or to run almost PHP 5.6

Zend Framework 2 error

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.

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.

Categories