Symfony Assetic Dump get class not Found Exception - php

When I tries to assetic dump php app/console assetic:dump --env=prod, I got Error Like
[Symfony\Component\Debug\Exception\ClassNotFoundException]
Attempted to load class "Twig_Filter_Method" from the global namespace.
Did you forget a "use" statement?
In Browser Run my Project It is display error like :-
ClassNotFoundException in BootstrapIconExtension.php line 51:
Attempted to load class "Twig_Filter_Method" from the global namespace.
Did you forget a "use" statement?
Anyone have any Suggestion please let me know ..

Change
'apply_filter' => new \Twig_Filter_Method($this, 'applyFilter'),
to this
'apply_filter' => new \Twig_SimpleFilter('apply_filter', array($this, 'apply_filter')),

I had the same issue; for me it was related with the liip imagine bundle version i was using. I have changed that version and it worked smoothly

Related

Class not found after "require_once"

I get the following error:
`Fatal error: Class 'DummyClass' not found in...`
<?php
require_once("3rdparty/simplesaml/lib/_autoload.php");
class login extends DummyClass { (this is the line the error refers to)
[...]
}
?>
If I comment out the require_once it works perfectly fine.
DummyClass is defined externally and can be found in the prepend-file. (I don't think it matters for this problem as it works as expected if I comment out require_once)
The path to the file should also be correct as it gives me a "Failed opening required..." Error if I change the path.
I also tried switching between PHP 5.6 and 7 - no difference.
So, I would like to ask you for help. Do you have any hints / ideas, why I might get that error?
Problem solved.
The old framework was using the old __autoload function, which is deprecated.
SimpleSAMLPHP used the new function. Those autoload-combinations cause one of them to override the other.
Solution:
Switch from __autoload to spl_autoload_register.
Similar Question: Override vendor autoload composer

ClassNotFoundException in SecurityExtension.php line 20

I have a quite mature project and I decided to move it to a different development environment. After setting everything up, I am now getting this exception:
ClassNotFoundException in SecurityExtension.php line 20:
Attempted to load class "Twig_Function_Method" from the global namespace.
Did you forget a "use" statement?
Where is this coming from? I am not even sure where to start.
By the stack trace, seems like it is something to do with assetic.
However, when I execute console command, for example cache:clear.
I am getting this:
[Symfony\Component\Debug\Exception\ClassNotFoundException]
Attempted to load class "Twig_Function_Method" from the global namespace.
Did you forget a "use" statement?
Similar, but now I am not even getting any more details than that.

Symfony console component, class not found

I'm using the console component without Symfony standard edition and I'm working on my application.php file. When I run it it says:
Fatal error: Class 'GenerateTableCommand' not found in D:\ConnectCommand\vendor\application.php on line 10
My code:
<?php
require __DIR__.'\autoload.php';
use Symfony\Component\Console\Application;
$application = new Application();
$application->add(new GenerateTableCommand());
$application->run();
?>
My repository can be found here if needed: https://github.com/guuse/ConnectCommand
Any help is greatly appreciated.
First of all there's no \GenerateTableCommand, as stated in the error message.
This class is under AppBundle\Command namespace, so it's full name is AppBundle\Command\GenerateTableCommand.
You should add use statement at the beggining:
use AppBundle\Command\GenerateTableCommand;
Anyway, you'll probably encounter further issues with loading this class, since you do not really have any autoloaders for your custom code, so PHP won't be able to load this class.
Also mixing 3rd party code with your own (in vendor directory) is not a good idea.

using ckeditor in symfony3

I try to use ckeditor in symfony3, I successfully installed it but get an error when I try to us it in my form as described in tutorial (https://symfony.com/doc/current/bundles/IvoryCKEditorBundle/index.html):
$builder->add('content', CKEditorType::class);
but that produces this error:
Type error: Argument 1 passed to
Ivory\CKEditorBundle\Form\Type\CKEditorType::__construct() must be an
instance of Ivory\CKEditorBundle\Model\ConfigManagerInterface, none
given
it looks like, there is a problem because a FormType should not demand params in its constructor, am I wrong?
I had the same error and solved it by adding CKEditorBundle to AppKernel.
This was stated in the comments of CountZero's answer. You can find IvoryCKEditorBundle installation notes here.
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Ivory\CKEditorBundle\IvoryCKEditorBundle(),
// ...
);
// ...
}
}
There are no bugs in IvoryCKEditorBundle. If you provide your composer.json, results of commands bin/console debug:container and bin/console config IvoryCKEditorBundle it'll really help me to give you more precise answer.
it looks like, there is a problem because a FormType should not demand params in its constructor, am I wrong?
You are wrong, CKEditorType may demand params in its constructor, and it does so in the current version.
There's something wrong with file vendor/egeloen/ckeditor-bundle/Resources/config/form.xml
It should configure (provide) service dependencies for CKEditorBundle, but it doesn't.
I would try to update composer, clear cache and debug service container configuration for this bundle, it should look like this:
⇒ composer update
⇒ bin/console cache:clear
⇒ bin/console debug:container|grep ivory
ivory_ck_editor.config_manager Ivory\CKEditorBundle\Model\ConfigManager
ivory_ck_editor.form.type Ivory\CKEditorBundle\Form\Type\CKEditorType
ivory_ck_editor.plugin_manager Ivory\CKEditorBundle\Model\PluginManager
ivory_ck_editor.renderer Ivory\CKEditorBundle\Renderer\CKEditorRenderer
ivory_ck_editor.styles_set_manager Ivory\CKEditorBundle\Model\StylesSetManager
ivory_ck_editor.template_manager Ivory\CKEditorBundle\Model\TemplateManager
ivory_ck_editor.twig_extension Ivory\CKEditorBundle\Twig\CKEditorExtension

using PayWithAmazon with symfony 2 - installed with Composer

I installed this package via composer:
composer require amzn/login-and-pay-with-amazon-sdk-php
composer update
I added this to my Controller file:
use PayWithAmazon\Client;
... and would like to use the Client class, provided with this package.
$amazonClient = new PayWithAmazon\Client($this->amazonCredentials);
The error message of the framework:
ClassNotFoundException in CartController.php line 185: Attempted to load
class "Client" from namespace "**Microsite\FrontBundle\Controller\PayWithAmazon**".
Did you forget a "use" statement for e.g.
"Symfony\Bundle\FrameworkBundle\Client",
"Symfony\Component\BrowserKit\Client",
"Symfony\Component\HttpKernel\Client",
"Guzzle\Service\Client" or "Guzzle\Http\Client"?
`
Can anyone tells me what i do wrong?
How do I change the namespace for "Client" class from Microsite\FrontBundle\Controller\PayWithAmazon to the right one?
(I did not have problems with other packages...)
Cheers
Greg
I will suggest you do follow
use PayWithAmazon\Client as AmazonClient;
...
$amazonClient = new AmazonClient($this->amazonCredentials);

Categories