I removed a property from my Entity and did
php app/console doctrine:Scheme:update --force
then
php app/console cache:clear --env=dev
The database is updated fine, however when I run the code the entity is still looking for the property I deleted.
Property myBundle\Entity\Name::$oldproperty does not exist (500 Internal Server Error)
How do I update this. Note I'm using APC cache? Thanks
It seems you probably not be able to clear the query-cache in CLI (app/console) since the console can't (or is not allowed to) clear the APC Cache. So you had to clear the APC Cache manually.
$ php app/console doctrine:cache:clear-result
And if that doesn't work, clear the APC Cache (or whatever cache you use) manually.
Related
I am in development mode (APP_ENV=dev in .env), and everytime I change entities and run the 'make:migration' command, it returns me that there is no database changes.
After I run the 'cache:clear' command, it takes the changes into account and makes the migration file.
It's quite annoying. Do you have any idea from where it could come ?
I use the 'symfony server:start' to run the dev server, maybe it comes from here ?
If this is an annotation cache from a bundle that causing the issue, simple cache:clear might not help. Did you try do run doctrine:migration:diff?
You can also try to use --flush with your commands:
php bin/console doctrine:cache:clear-query --env=dev --flush
php bin/console doctrine:cache:clear-result --env=dev --flush
php bin/console doctrine:cache:clear-metadata --env=dev --flush
Update after comments:
What I meant, the complete way you use to deploy the entity changes.
As per Symfony 4, an entity update flow might look like below:
Update your entity class - your php/annotation changes
Clearing ALL Metadata cache entries
php bin/console doctrine:cache:clear-metadata
Generate a migration by comparing your current database to your mapping information.
php bin/console doctrine:migrations:diff
View the status of a set of migrations
php bin/console doctrine:migrations:status
Deploy migration
php bin/console doctrine:migrations:migrate --all-or-nothing
using option --all-or-nothing multiple migrations ran at the same time will be wrapped in a single transaction.
If one migration fails, all migrations will be rolled back.
More about migrations from official source: https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html
Similar problem explained also here: Update an entity in Symfony 4?
Hope this will help and fix your issue.
I have cleared my symfony2 application and now cannot run the application because cannot generate proxies for entities from the command line while a few have actually been generated by default.
I have tried to run the command below which usually did the trick in earlier versions of symfony/ doctrine:
php bin/console doctrine:ensure-production-settings --no-debug --env=prod
But this time I only get the following response:
Query Cache uses a non-persistent cache driver, Doctrine\Common\Cache\ArrayCache.
Anyone know how to solve this?
Try
php bin/console cache:warmup --env=prod --no-debug
How ever the command you are trying
php bin/console doctrine:ensure-production-settings --no-debug --env=prod
is not for generating proxies, but for verifying that Doctrine is properly configured for a production environment.
And to actually to make sure you are ready for production , you need to use one of the cache drivers mentioned here
.
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.
I can't find any documentation as to how to configure APC with Symfony2. I don't want to write any specific code or have anything advanced, just the basic APC setup with Symfony2.
I've uncommented the two lines in app.php and everything seems ok (the site runs for a start).
However...
(1) I hear people talk about "restarting APC" - what does that mean? Can I not just run this any time I want a full clean:
php console cache:clear --env=prod --no-debug
(2) In app/config_prod.yml, I see this:
framework:
router:
strict_requirements: null
#validation:
# cache: apc
...what does uncommenting that do?
It seems too easy just to uncomment the two lines in app.php. SUrely there must be more config options. Again I don't want an advanced setup.
I don't even know if APC is running, but considering the site runs that tells me it is (before it didn't and I needed to install APC in PHP).
When I searched "APC" in the Symfony2 cookbook it returned literally nothing.
apc_clear_cache() will clear the system cache and calling apc_clear_cache('user') will clear the user cache. -> https://stackoverflow.com/a/911219/1501189
also, to get apc up and running in symfony, make sure u enable it in your php.ini for CLI aswell! not only in your php.ini that your apache uses, this had me fooled for a while when i was trying to get this running myself
To check if symfony is using APC, click the profiler at the bottom of the page (when in dev environment), then click config on the left, and it will tell your wether or not APC is enabled
I am using Symfony 2.0 beta3 and I am facing a rather strange problem. I have
set up the ORM with a sqlite database following the instructions of
the website but when I type:
php app/console doctrine:database:create
then
php app/console doctrine:schema:create
and finally
php app/console doctrine:schema:update --force
I don't get any error (for example last command outputs "Database
schema updated successfully") but nothing is actually inserted into
the database. The table aren't even created. The database file is
generated after the first command but remains empty.
Since I have configured FOS_UserBundle I should have for example a
table fos_user…
When I type
php app/console doctrine:schema:update --dump-sql
It shows that three SQL requests are pending… If I execute these three requests using
SQLiteManager, it works (so the fos_user table is created)
but when I want to create a user using:
php app/console fos:user:create
I get a "SQLSTATE[HY000]: General error: 1 no such table: fos_user " error.
Why am I not given some error message when I run the first three
commands? Am I missing something?
I face the same behaviour using pdo_pgsql driver, except that the SQL
generated by the dump is not ANSI compliant so it can't be executed
for postgresql (use of datetime and autoincrement instead of timestamp
and serial)….
Any help would be much appreciated
I found this solution on the Symfony forums.
It would seem the helpers aren't creating two things that you need for the sqlite implementation to work correctly.
Firstly, in the parameters.ini for the project (tweak to suit):
database_path=%kernel.root_dir%/config/MyDatabase.db
Secondly, in the config.yml file in the doctrine.dbal section, add the following:
path: %database_path%
Then run:
php app/console doctrine:database:create
and it should generate the database for you in the app/config folder.
You will need to run:
php app/console doctrine:schema:create
to create the schema. Re-run the code that didn't work and it should work fine.
The FOSUserBundle is developed in sync to the symfony master.
Be sure to updated both, symfony and the FOSUserBundle.
Drop the schema (php app/console doctrine:schema:drop --force)
Manually check the db whether the schema is dropped. Otherwise do it per hand.
Clear the cache and ensure that it is writeable.
Run php app/console doctrine:schema:update --force again.