Symfony 2 server migration error - symfony

I have a Symfony 2 project that I have moved to a new server.
When I go to load the new website I get the following error:
PHP Fatal error: Class 'Doctrine\\Common\\Annotations\\AnnotationRegistry' not found in /var/www/corpsite/corpsite/app/autoload.php on line 61
Im very new to Symfony so any help is appreciated!

Moving a Symfony2 instance can lead to issues with the autoloading,
you should run:
composer.phar dump-autoload --optimize
(the optimize option is for PROD ONLY, and you will get a boost bonus).
Don't forgot also to clear the SF2 cache:
app/console cache:clear --env=prod --no-debug
or...
rm -rf app/cache/*
The error can also be from non existing vendors, composer install is the answer then.

Related

Syntax error in Doctrine?

We are working on our first site with Symfony. In development, everything works. But when we are on production, nothing works!
Trying to use app_dev.php, we see:
Parse error: syntax error, unexpected 'const' (T_CONST), expecting
variable (T_VARIABLE)" in AbstractProxyFactory.php (line 72), script
of Doctrine (in composer.json, we ask for Doctrine > 2.5)
What does that mean?
Clear the cache for the production environment.
bin/console cache:clear --env=prod
Switch to the production environment with composer during deployment.
composer install --no-dev --optimize-autoloader

Symfony2 Sylius assets install

I am trying to install assets on my sylius project, and I am facing problem :
COMMAND: php app/console sylius:install:assets
ERROR AFTER EXECUTING COMMAND: This command terminated with a permission error
I found solution of a problem, before you guys try to install assets be sure to clear cache, but you might get into a trouble with memory, so edit your
app/console file and add ini_set('memory_limit','-1');
and after that run cache clear, and install assets and everything will be fine :)

I cannot clear the cache (because the cache is outdated)

Trying to deploy my updated Symfony2 application, I ran into the following problem.
(note that my application uses the new Symfony 3 directory structure. replace bin/console with app/console and var/cache with app/cache if you're using the current directory structure)
I have recently renamed one of my service classes (VariantSlugListener). When deploying the application on the staging server, I got the following error when running bin/console assetic:dump --env=prod:
PHP Fatal error: Class 'MyBundle\Listener\VariantSlugListener' not
found in
/var/www/example.com/staging/var/cache/prod/appProdProjectContainer.php
on line 494
Line 494 of appProdProjectContainer.php contains the following code:
return $this->services['3f288d4f09c9906944ba7e17358f669b942397baf9d79d5ff0737bb756df7023_1'] = new \MyBundle\Listener\VariantSlugListener();
It is no surprise that \MyBundle\Listener\VariantSlugListener can not be found, since it has been renamed to \MyBundle\EventListener\VariantSlugSubscriber with the latest update. The solution would be to simply clear Symfony's cache.
However, when trying to clear the cache (using bin/console cache:clear --env=prod) I get the exact same error as with the assetic:dump command. So I get an error because my Symfony cache is outdated, but I can not clear the cache because of the error.
I can probably get around this by manually deleting the contents of the var/cache directory, but that doesn't feel like the best solution.
Am I missing something?
Probably you are triggering some events that are handled in your VariantSlugListener when doing 'cache:clear'. So your only choice is to just remove contents of the cache directory or to replace the value manually and then run cache:clear to warm up the cache.

'The parameter "debug.error_handler.throw_at" must be defined' error after updating to Symfony 2.6

After updating Symfony with Composer to version 2.6 it gives this error:
[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException] The parameter "debug.error_handler.throw_at" must be defined.
manualy clear application cache -
remove all files in /app/cache:
rm -r app/cache/*
and then warmup cache for needed environment like that:
app/console cache:warmup --env=prod

Symfony 2 -> Composer and CloudControl

I have a little problem to setup Symfony 2 on Cloudcontrol,
I followed the instructions and installed a Symfony 2 framework, changed the document root and so on.
Now when I try to push the changes to server server, it loads the dependencies from the composer.json and then it failed with a message :
[RuntimeException]
Could not scan for classes inside "/srv/tmp/builddir/code/vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Resources/stubs" which does not appear to be a file nor a folder
This file is a vendor package, loaded from composer.
I have the same effect with a default composer.json file from a sample project (SF2)
Localy it works very well!
Can some one give me a hint ?
Got same error after setting "minimum-stability":"dev" and running composer update.
for unknown reason symfony/symfony (dev-master ...) kept failing to download from source thus was being loaded from cache.
what worked for me was a mix of previous answers:
$ rm -rf vendor/symfony
$ composer clearcache
$ composer install
Sometimes I had to clean composer cache to remove strange errors, usually it's in
/home/user/.composer/cache
You can also try to update composer with
php composer.phar self-update
I hope it runs for you.
I had the exact same error in my development directory.
What fixed it was :
$ rm -rf vendor/symfony
$ php composer.phar install
It reinstalled symfony/symfony, symfony/icu, symfony/assetic-bundle, symfony/monolog-bundle and symfony/swiftmailer-bundle and now everything works !

Resources