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
Related
runtime: macos big sur, air m1, docker with php8
I wanted to make a collection serializer injectable via yii2 config so that the container provides an interface for me to work with and this is what I wrote:
interface ClaimStateFeeChargeCollectionSerializerInterface
{
public function serialize(ClaimStateFeeChargeCollection $collection): string;
}
and
class ClaimStateFeeChargeCollectionSerializer implements ClaimStateFeeChargeCollectionSerializerInterface
{
// implementation
}
and the config is as follows:
'components' => [
'collectionUnloadSerializer' => [
'class' => ClaimStateFeeChargeCollectionSerializer::class
]
]
the code for actually getting the dependency:
Yii::$app->collectionUnloadSerializer->serialize($collection)
but then when I run the code yii throws an exception saying that the interface cannot be found:
however, when I rename the interface to absolutely anything else it works just fine
am I missing something? something completely not obvious?
UPD: apparently, nothing breaks in php7.2
UPD2: I tried every version from 7.2 to 8 and in all of them the code worked; so I guess the issue is resolved but if you still encounter this or know why this happened - please leave a reply;
I tried to run this code in php7.2 but that forced me to run composer update
After this I run docker with php8 again and everything worked
I dont know what helped: updating composer or restarting the container, it may be both, but composer missing some classes to autoload seems like a reasonable reason for this issue
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
recently upgraded a 5.3 project to 5.4 and all seemed good.
Today I started to implement Dusk however had hit an issue when running the example test
☁ footy-finance [5.4] ⚡ php artisan dusk
PHPUnit 6.0.0 by Sebastian Bergmann and contributors.
E 1 / 1 (100%)
Time: 162 ms, Memory: 6.00MB
There was 1 error:
1) Tests\Browser\ExampleTest::testBasicExample
ReflectionException: Class config does not exist
/Users/owen/Sites/footy-finance/vendor/laravel/framework/src/Illuminate/Container/Container.php:681
/Users/owen/Sites/footy-finance/vendor/laravel/framework/src/Illuminate/Container/Container.php:565
/Users/owen/Sites/footy-finance/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:105
/Users/owen/Sites/footy-finance/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php:263
/Users/owen/Sites/footy-finance/vendor/laravel/dusk/src/TestCase.php:203
/Users/owen/Sites/footy-finance/vendor/laravel/dusk/src/TestCase.php:40
I've had a look at line 40 of TestCase.php and its
public function baseUrl()
{
return config('app.url');
}
So it does look like something to do with the global config helper anybody have any ideas?
I'm running
PHP 7.0.14
Laravel/Framework 5.4.8
Laravel/Dusk 1.0.5
The full composer.lock can be seen https://gist.github.com/OwenMelbz/c05172b33f6eb4483e37a56469b53722
Fingers crossed you guys have some ideas!
Cheers :)
I had this error in the log
Class config does not exist
the problem with me was that in the .env file I had set a configuration variable in the following way:
APP_NAME=Application Name
note the space. When I changed it to this:
APP_NAME="Application Name"
the problem got fixed
The issue is with .env file
App_Name
in the original file its written this way>>> APP_NAME=Application Name
Make it like this APP_NAME="Application Name"
In my case, this solution works:
1) Remove all contents of the bootstrap/cache folder
2) Run the composer dump command
For anybody else who has had this issue.
I had prefer stable set in the composer file, which installed PHPUnit 6.
This was "made stable today" - thus it installed during a composer update.
Downgrading to PHPUnit 5 fixes the issue - so was bad timing starting it today.
I just ran into the the same issue, in my case the .env was all clean, no unwrapped empty spaces.
This error message can also occur when writting/debugging a test case, using the setup() method in that test, forgetting to call parent::setup() as the first statement in that function.
protected $stuf;
function setup() {
parent::setup();
$this->stuf = 'stuf';
}
I found very useful info here on what else could happen when you're getting this error message.
I've also had this issue. For me it was caused by calling the config() function inside a dataProvider method. DataProviders are called before the createApplication() method initialises the application, and populates the DI container. Hence config() fails because the app('config') call in the helper function can't resolve the config class from the container.
I'm very late for the party here but for anyone experiencing the same issue with Laravel's unit test and none of the above solutions work, you can look into mine and see if this might help.
In my case, I was trying to call a method that will remove all the test keys that persisted in my Redis database when I run the unit test. The method is called in the tearDown method of the class. The error occurs because the parent constructor is called before the actual tearDown code is executed. That's the reason why I'm having the error.
Instead of this one......
/**
* tearDown is executed after test stub
*/
protected function tearDown()
{
parent::tearDown();
$this->deleteTestKeys();
}
Change it to this one...
protected function tearDown()
{
$this->deleteTestKeys();
parent::tearDown();
}
In this case, the class' is not totally destroyed yet and the Laravel's config method will get called accordingly.
I had this in a Lumen application today. After some investigation and playing around, I found that it was because in PHPStorm it was adding the --no-configuration option onto the phpunit command because I hadn't configured my PHPUnit setup for the project in the IDE.
I corrected that by clicking 'Run > Edit Configurations' and then under 'Defaults > PHPUnit' click the little button to the far right of the 'Use alternative configuration file:' option and set the 'Default configuration file:' to the full path to your project's phpunit.xml.
Hope this helps!
I saw this error after following some dodgy installation instructions for a third party module, which said to register a service provider in bootstrap/app.php
$app->singleton(...);
$app->singleton(...);
$app->register(\Third\Party\ServiceProvider::class);
This caused $this->app['config'] to generate the error BindingResolutionException: Target class [config] does not exist.
I fixed it by putting it in config/app.php, where it belongs:
/*
* Package Service Providers...
*/
Third\Party\ServiceProvider::class,
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);
I'm having a problem whilst trying to create a command with Symfony2's Console component, in a full Symfony stack app.
If i try to pass my services in via DI, the command throws the following error when i try to run it:
[Symfony\Component\Debug\Exception\ContextErrorException]
Notice: Trying to get property of non-object
If I create the command with ContainerAwareCommand and try to get my service with
$this->getContainer()->get('mtgu.api.card.list.response.data');
I get
[LogicException]
The container cannot be retrieved as the application instance is not yet set.
My service is defiantly being loaded, as its used in a front end controller. This problem gets stranger, as if I pass a repository service - I don't get this problem!
Is there some trick to setting up a service to be passible by this? Or have I messed up my configuration somehow?
Im "autoloading" all my services by doing this in my DI Extension rather than including them all through the the main services.yml. I thought this or the ordering of the yml includes maybe effecting it - but I have tried manually including everything but still no joy!
$finder = new Finder();
$finder->name('services.yml');
/**
* #var $file SplFileInfo
*/
foreach($finder->in(__DIR__.'/../') as $file) {
$loader = new Loader\YamlFileLoader($container, new FileLocator($file->getPath()));
$loader->load('services.yml');
}
Vendor/Bundle/Command/services.yml
services:
mtgu.command.slugify:
class: MightyStudios\MtguBundle\Command\SlugifyCommand
tags:
- { name: console.command }
arguments:
- #mtgu.api.card.list.response.data
I think this maybe just some config issue, but Google has failed me to find the answer! Has anyone else run into this problem and can they shed any light!?
Many thanks
A better structure would be to put your services files in the Resources/config directory of your bundle (See also all core bundles). However, that's aside.
The problem is described by the exception: The container cannot be retrieved as the application instance is not yet set. Which is thrown in the ContainerAwareCommand#getContainer() method when $this->application is null. The application is set in the first line of the Application#add() method.
This means that you call $this->getContainer() before you add the command to the application. Maybe you use it in your constructor?
If so, remove it and only use the container in Command#execute(), Command#interact() or Command#initialize().