I've tried updating Symfony to v2.7.40 today. At the end of the update process while clearing the cache I encounter
PHP Fatal error: Class 'Twig\Extension\AbstractExtension' not found
In my composer.json I already have required and installed "twig/extensions": "~1.5"
Do I need to update any other bundle/library?
Thank you
Related
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.
just started working on a project, I ran composer update and was greeted with a exception when trying to clear cache.
When I try to run php bin\console server:run I am greeted with this message:
php bin\console server:run
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Fatal error: Class 'AppKernel' not found in CoreBundle\bin\console:27
Stack trace:
#0 {main}
thrown in CoreBundle\bin\console on line 27
Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Fatal error: Class 'AppKernel' not found in CoreBundle\bin\console on line 27
Symfony\Component\Debug\Exception\FatalThrowableError: Fatal error: Class 'AppKernel' not found in CoreBundle\bin\console on line 27
Call Stack:
0.0112 427536 1. Symfony\Component\Debug\ErrorHandler->handleException() CoreBundle\vendor\symfony\symfony\src\Symfony\Component\Debug\ErrorHandler.php:0
Another strong possibility, particularly if the project has been updated from a v2.7 project (or before) is that the AppKernel is just not known to Composer. It is now best practice to not manually require/include the file, (so those lines are removed from web/app_*.php, and bin/console.php). but instead have it autoloaded. However, this requires a line in Composer so that it can be found. Only the composer autoloader would ever be included manually, which can then load everything else.
"autoload": {
"files": ["app/AppKernel.php"],
"psr-4": { // etc...
There are two possible reasons for this.
First your autoloader is trashed or can't find files
composer dump-autoload
Second reason could be, that your var directory isn't writable in which the cache file for symfony is placed.
Just check the permissions.
Also take a close look into the log files.
Maybe it tells you what the real Problem is.
(Like an issue with syntax etc.)
For some reason, I had to explicitly add src/Kernel.php to autoload. So my composer.json autoload section became:
"autoload" : {
"files": ["app/AppKernel.php",
"src/Kernel.php"],
"psr-4": { "": "src/"},
"classmap": [
"app/AppKernel.php",
"app/AppCache.php"
]
}
After adding this, running composer dump-autoload did the trick.
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
I just tried to install a fresh instance of Laravel as described in the docs ( http://laravel.com/docs/quick#installation - "Via Composer"). Got this error from Composer:
...
Writing lock file
Generating autoload files
PHP Fatal error: Class 'Monolog\Logger' not found in ...\src\vendor\laravel\framework\src\Illuminate\Log\LogServiceProvider.php on line 23
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'Monolog\\Logger' not found","file":"...\\src\\vendor\\laravel\\framework\\src\\Illuminate\\Log\\LogServiceProvider.php","line":23}}Script php artisan clear-c
ompiled handling the post-install-cmd event returned with an error: PHP Fatal error: Class 'Monolog\Logger' not found in ...\src\Illuminate\Log\LogServiceProvider.php on line 23
PHP Fatal error: Class 'Monolog\Logger' not found in ...\src\Illuminate\Log\LogServiceProvider.php on line 23
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'Monolog\\Logger' not found","file":"...\\src\\vendor\\laravel\\framework\\src\\Illuminate\\Log\\LogServiceProvider.php","line":23}}Script php artisan optimiz
e handling the post-install-cmd event returned with an error: PHP Fatal error: Class 'Monolog\Logger' not found in ...\src\Illuminate\Log\LogServiceProvider.php on line 23
Uhm, what to do now? Tried to post it on the official forums but that wasn't possible due to an error there (forums are based on Laravel... yeah that's Karma!).
Solution: "composer dumpautoload -o"
I wanted to integrate twitter-bootstrap in my Symfony2 project and trying to make it work, I followed documentation is BootstrapBundle.
After installing all dependencies set in composer.json, i get this error:
Fatal error: Interface 'Knp\Menu\Matcher\Voter\VoterInterface' not found in /var/www/cv- editor/vendor/mopa/bootstrap-sandbox-bundle/Mopa/Bundle/BootstrapSandboxBundle/Navbar/Example/Voter/RequestVoter.php on line 12
Have you any idea ?
After debvugging, i found that there is a problem in dependencies of MopaBootsrapBundle which works with Knp-menu-bundle version 1.2