Symfony 3.3 Getting ClassNotFoundException - php

I have updated my system to from Symfony 3.2.x to Symfony 3.3.x and now I cam getting this error for every bundle in my application:
Attempted to load class "XXXXXXXXPublicBundle" from namespace "XXXXXXXX\PublicBundle".
Did you forget a "use" statement for another namespace?
In my PublicBundle I am using the namespace:
namespace XXXXXXXX\PublicBundle;
When I try and run php composer.phar update I get this error too:
Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "XXXXXXXXPublicBundle" from namespace "XXXXXXXX\PublicBundle".
What is going on - I have no clue what to do. Any assistance?

Related

Can not load class "Kernel" from namespace "App" [duplicate]

I'm currently facing an important issue when i want to run any "php bin/console" command:
Symfony\Component\ErrorHandler\Error\ClassNotFoundError^ {#29
#message: """
Attempted to load class "Kernel" from namespace "App".\n
Did you forget a "use" statement for "Symfony\Component\HttpKernel\Kernel"?
"""
#code: 0
#file: "./bin/console"
#line: 41
}
2020-06-11T15:43:20+00:00 [critical] Uncaught Error: Class 'App\Kernel' not found
While my Kernel.php class is normally defined in src/Kernel.php
I am working with Symfony 5
I manage to solve my issue performing 3 successive actions :
delete "vendor" folder (I saved it in another folder just in case)
delete "cach-dev" folder
run "composer update" command
Hope it can help other people to solve their issue

Downgrading Twig: Uncaught Error: Call to undefined method Twig\Environment

I'm using Symfony 4.4 on a project and I need to use stfalcontinymce. Since I'm on SF4 I need the version 2.4. So I did this:
composer require stfalcon/tinymce-bundle=2.4
But then I get this error:
!! 11:03:44 CRITICAL [php] Uncaught Error: Class 'Twig_Extension' not found ["exception" => Error { …}]
!!
!! In StfalconTinymceExtension.php line 13:
!!
!! Attempted to load class "Twig_Extension" from the global namespace.
!! Did you forget a "use" statement?
Someone told me that it's because this version doesn't get along with Twig 3 so I need to downgrade my Twig version. I then did this to downgrade Twig:
composer require twig/twig=2
But then I get this error:
13:14:07 CRITICAL [php] Uncaught Error: Call to undefined method Twig\Environment::registerUndefinedTokenPa
rserCallback() ["exception" => Error { …}]
!!
!! In srcApp_KernelDevDebugContainer.php line 2040:
!!
!! Attempted to call an undefined method named "registerUndefinedTokenParserCallback" of class "Twig\Environm ent".
!! Did you mean to call e.g. "registerUndefinedFilterCallback" or "registerUndefinedFunctionCallback"?
I tried adding in composer.json
"twig/extensions": "*"
Then composer install, then running the command:
composer require stfalcon/tinymce-bundle=2.4 -W
And I get this error:
!! 13:49:04 CRITICAL [php] Uncaught Error: Call to undefined method
Twig\Environment::registerUndefinedTokenParserCallback() ["exception" => Error { …}]
!!
!! In srcApp_KernelDevDebugContainer.php line 2045:
!!
!! Attempted to call an undefined method named "registerUndefinedTokenParserCallback" of class "Twig\Environment".
!! Did you mean to call e.g. "registerUndefinedFilterCallback" or "registerUndefinedFunctionCallback"?
I'm really lost here. Can someone help? thanks
Your executed commands don't seem to be possible on my system at all since there will be version constraint conflicts.
Instead of restricting to one version for your dependencies, you should use a constraint.
Your require in composer.json may contain something like the following
"twig/twig": "^2",
"stfalcon/tinymce-bundle": "2.4.*",
"twig/extra-bundle": "^2"
The constraints are explained here. But the ^2 basically means >= 2.x.x and < 3.0.0
For the tinymce bundle I used the above because of the this GitHub issue
Furthermore twig/extensions seems to be deprecated, and this GitHub issue mentions twig/extra-bundle which is needed and may be its replacement.

Uncaught Error: Class 'App\Kernel' not found

I'm currently facing an important issue when i want to run any "php bin/console" command:
Symfony\Component\ErrorHandler\Error\ClassNotFoundError^ {#29
#message: """
Attempted to load class "Kernel" from namespace "App".\n
Did you forget a "use" statement for "Symfony\Component\HttpKernel\Kernel"?
"""
#code: 0
#file: "./bin/console"
#line: 41
}
2020-06-11T15:43:20+00:00 [critical] Uncaught Error: Class 'App\Kernel' not found
While my Kernel.php class is normally defined in src/Kernel.php
I am working with Symfony 5
I manage to solve my issue performing 3 successive actions :
delete "vendor" folder (I saved it in another folder just in case)
delete "cach-dev" folder
run "composer update" command
Hope it can help other people to solve their issue

FosOauthServerBundle Propel BaseClient not found

I'm using doctrine orm but somehow I get an error that the propel BaseClient is not found (a class usually autogenerated by propel).
Either it's a bug or I'm doing something wrong?
fos_oauth_server:
db_driver: orm
client_class: Diligentia\OAuthBundle\Entity\Client
access_token_class: Diligentia\OAuthBundle\Entity\AccessToken
refresh_token_class: Diligentia\OAuthBundle\Entity\RefreshToken
auth_code_class: Diligentia\OAuthBundle\Entity\AuthCode
service:
user_provider: fos_user.user_manager
The error:
PHP Fatal error: Class 'FOS\OAuthServerBundle\Propel\om\BaseClient' not found in /var/www/redwood/vendor/friendsofsymfony/oauth-server-bundle/Propel/Client.php on line 19
Fatal error: Class 'FOS\OAuthServerBundle\Propel\om\BaseClient' not found in /var/www/redwood/vendor/friendsofsymfony/oauth-server-bundle/Propel/Client.php on line 19
Segmentation fault
Seems to me it shouldn't even attempt to load it.
predis wasn't installed with composer causing my caching not to work.
Due to that the User Bundle was unable to obtain which db driver I used and putting propel as default causing the unrelated error and my inability to find the issue for a long time.

message class 'mongoclient' not found codeigniter

I am trying to setup mongo db in codeigniter after doing setup when I run my controller getting this error. I have tried similler error on stackoverflow but no luck. here is the error:
Fatal error: Class 'MongoClient' not found in /var/www/html/grant/application/libraries/Mongo_db.php on line 216
A PHP Error was encountered
Severity: Error
Message: Class 'MongoClient' not found
Filename: libraries/Mongo_db.php
Line Number: 216
Backtrace:
Your Mongo_db class is expecting that the MongoClient class has already been loaded and Mongo_db is trying to instantiate it. Your question didn't include the link to the Mongo library you are using so I'm unable to debug further, however here are the basic steps.
Before loading your Mongo_db library try loading Mongo_client
$this->load->library('mongo_client');
If your libraries rely on composer autoloader make sure that you have included the autoloader class somewhere in your bootstrap or configuration
include 'vendor/autoload.php'
If your libraries rely on composer, you may also want to check your autoload make sure you are including your libraries directory in the class map:
{
"autoload": {
"classmap": ["application/libraries"]
}
}
If you updated your autoload configuration in your composer.json file make sure to run this command
composer dump-autoload

Categories