The problem is very simple. The applications works as expected, no problems, sessions work, etc.
But when I try to clear the cache:
bin/console c:c
// Clearing the cache for the dev environment with debug true
In RequestStack.php line 105:
There is currently no session available.
Any ideas?
Symfony version 6, all the latest packages.
The issue was in one of the Services, trying to call
requestStack->getSession()
in the __construct method.
The key to finding this error was to get a stack trace, using the bin/console c:c -vvv
Related
I thought this PR fixed the issue I am having - but I have this patch and it's still not working as I expected - what am I missing or mis-understanding?
https://github.com/symfony/symfony/pull/28533
I have created a .env.test with the following:
DATABASE_URL_TEST=mysql://apps:#localhost:3306/mydb_test
Then I dropped a doctrine.yaml inside the config/packages/test directory.
Symfony v4.2.3
However when I run this command from CLI:
APP_ENV=test bin/console doctrine:database:create --env=test
I am getting an error:
Environment variable not found: "DATABASE_URL_TEST".
Clearly the .env.test file is not being loaded - how do I get a specific environment configuration file to load - other than .env???
If indeed your application was a Symfony 3.x application at some point, what I would guess is that, during the upgrade process, those two lines out of the UPGRADE procedure were missed:
Then, upgrade the contents of your console script and your front
controller:
bin/console:
https://github.com/symfony/recipes/blob/master/symfony/console/3.3/bin/console
public/index.php:
https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/public/index.php
Indeed, it seems like bin/console have been changed recently to reflect the adaptation done on the DotEnv component: https://github.com/symfony/recipes/commit/3e471cbc7d359b3ab245f3b0748d698e8d29692c#diff-2af50efd729ff8e61dcbd936cf2b114b
Mind that you'll also need https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/4.2/config/bootstrap.php
I had a very similar problem. My issue was that my phpunit.xml.dist was pointing to the wrong bootstrap file:
Previously:
bootstrap="vendor/autoload.php"
Changed to:
bootstrap="tests/bootstrap.php"
I am performing migration from Symfony 2.7 to Symfony 3+. Multiple components and dependencies have been updated.
I managed to fix configurations issues regarding firewall setup, forms and some extenstions (services).
Sorting one problem introduced me to another.
Now each time I run php bin/console I get an error:
[Symfony\Component\DependencyInjection\Exception\OutOfBoundsException]
The argument "3" doesn't exist.
I have tried to run it with -v or -vvv option and I only got:
Exception trace:
() at /xx/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Definition.php:242
Symfony\Component\DependencyInjection\Definition->getArgument() at /xx/vendor/sonata-project/core-bundle/DependencyInjection/Compiler/FormFactoryCompilerPass.php:48
Sonata\CoreBundle\DependencyInjection\Compiler\FormFactoryCompilerPass->process() at /xx/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php:139
Symfony\Component\DependencyInjection\Compiler\Compiler->compile() at /xx/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:710
Symfony\Component\DependencyInjection\ContainerBuilder->compile() at /xx/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:515
Symfony\Component\HttpKernel\Kernel->initializeContainer() at /xx/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:117
Symfony\Component\HttpKernel\Kernel->boot() at /xx/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:68
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /xx/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:121
Symfony\Component\Console\Application->run() at /xx/bin/console:28
It looks like the issue with container compliation:
http://symfony.com/doc/current/components/dependency_injection/compilation.html
Some old setup passed validation but it is not consumed properly by DependencyInjection Compiler.
I have fallowing questions:
How I can debug it?
What can cause problem like this?
How to fix it?
Thanks!
I would like to use mmoreram/gearman-bundle in Symfony. I already installed it, but when i call
php app/console gearman:job:execute PrGwBundleGearmanWorkerPrWorker~doSomething
I only get an overview an no result from the Job itself.
Also, I didn't understand yet how to call a Job from inside php. The doku doesn't really tell me how and there are - unfortunately - no tuts in the web for it :(
I think I first have to create a instance of $gearman. But how, there is no explanation of it :(
http://gearmanbundle.readthedocs.org/en/latest/running_jobs.html
It would be great if someone could help me getting into the bundle so that I can use it :
Thanks and kind regards
You have to run something like
php app/console gearman:job:execute PrGwBundleGearmanWorkerPrWorker --no-interaction
Then your worker is started and running.
You can call a function on your job worker like this:
$gearmanClient->doBackgroundJob('PrGwBundleGearmanWorkerPrWorker~doSomething', $payload);
This will execute the doSomething Method on your PrGwBundleGearmanWorkerPrWorker.
You can see a list of all defined workers with:
php app/console gearman:worker:list
and get details of an worker with:
php app/console gearman:worker:describe PrGwBundleGearmanWorkerPrWorker
Then you will get an output containing a line starting with
#Worker\supervisord
The command behind this, can be used to start the worker from the commandline.
I installed FOS Userbundle to learn from it, but decided I didn't need it anymore. I then did the following to remove it. After removing, I ran composer update.
removed the bundle from the vendor folder
removed from the appKernel
removed from the composer.json file
removed the entity User.php file
removed the settings from config.yml, security.yml, routing.yml
Now when I attempt to clear cache for production mode I get the following error below. Clearing cache in dev mode works fine.
Can show me what I am doing wrong or what I am missing to remove FOS User Bundle and be able to clear cache in production mode?
PHP Fatal error: Class 'FOS\UserBundle\EventListener\LastLoginListener' not found in /var/www/html/HealthFitness/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php on line 142
PHP Stack trace:
PHP 1. {main}() /var/www/html/HealthFitness/app/console:0
PHP 2. Symfony\Component\Console\Application->run() /var/www/html/HealthFitness/app/console:27
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/html/HealthFitness/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:121
PHP 4. Symfony\Component\DependencyInjection\Container->get() /var/www/html/HealthFitness/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:86
PHP 5. appProdProjectContainer->getEventDispatcherService() /var/www/html/HealthFitness/app/bootstrap.php.cache:2037
PHP 6. Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher->addSubscriberService() /var/www/html/HealthFitness/app/cache/prod/appProdProjectContainer.php:343
Your error indeed probably come from a cache error.
Have you this error executing php app/console cache:clear --env=prod ?
You can else delete app/cache/prod/* manually.
In case you can't remove the files manually this should work as well.
You could also use a --no-warmup and --no-optional-warmers switches:
cache:clear --no-warmup --no-optional-warmers --env=prod
that way it should not try to recreate the cache of non existing classes and then do a
cache:warmup --env=prod
Manually removing cache is faster though, but you still warm it up.
I am pretty new to Symfony 2 and brand new to Gearman.
I am looking for a bundle to integrate Symfony 2 with Gearman.
mmoreramerino's bundle seems to be the most popular bundle according to packagist. Unfortunately something seems to be broken, the autoloader does not find the bundle.
Fatal error: Class 'Mmoreramerino\GearmanBundle\MmoreramerinoGearmanBundle' not found in ...
I tried switching to "dev-development" as I got from the issues that it was fixed in this branch, but it did not work for me as well.
Question: How can I install this bundle using Symfony 2.1.x?
Question 2: Are there any working & documented alternatives?
Edit In case someone else comes across this question: Here is how I got it up and running!
Install gearman, libgearman, the PECL extension for PHP (use recent versions!)
check that gearman shows up in phpinfo() (both cli and webserver version)
start gearmand in terminal 1 using "gearmand --verbose INFO" (you will see workers & clients connect to gearman - or not ;-))
start in terminal 2 reverse_worker.php from the gearman php extension example directory
start in terminal 3 reverse_client.php from the gearman php extension example directory
If this is working, you are ready for Symfony: install mmoreramerino/GearmanBundle using "dev-development"
copy dev.base.yml from the bundle to app/config/gearman/dev.yml
Now add TestWorker.php to your bundle as outlined in the documentation
enable the testWorker by using the console script "php app/console gearman:job:execute MmoreramerinoGearmanBundleWorkerstestWorker~test"
now you are able to send jobs to the listening testWorker in a Symfony controller (or somewhere else in Symfony). I had to specify the server though I am using the default host/port.
$gearman = $this->get('gearman');
$gearman->setServer('127.0.0.1',4730);
$gearman->doNormalJob('MmoreramerinoGearmanBundleWorkerstestWorker~test');
To install the bundle, you need to add the following line to composer.json
"Mmoreramerino/GearmanBundle": "dev-development"
and run composer update;
Then register it in app/AppKernel.php (it seems you have already done this)
new Mmoreramerino\GearmanBundle\MmoreramerinoGearmanBundle(),