I removed $hearAboutIndustry from the entity and now getting error below only in production server, not on local and staging server! Any idea why or solution?
Property Tete\AdminBundle\Entity\Customer::$hearAboutIndustry does not exist
500 Internal Server Error - ReflectionException
config_prod.yml
doctrine:
orm:
metadata_cache_driver: apc
result_cache_driver: apc
query_cache_driver: apc
What I have do to solve it so far:
Removed getter and setters from the entity.
Deleted whole cache and logs folders and re-created back, inc 777.
Just in case run cache:clear --env=prod
Searched hearAboutIndustry in all directories/files of the project. No reference at all.
Run doctrine:schema:update. DB is updated.
Run doctrine:generate:entities. Entity is updated.
app/console doctrine:cache:clear-metadata
app/console doctrine:cache:clear-query
app/console doctrine:cache:clear-result
As Adam suggested above in comment, we better restart apache if all the above solutions have been tried and getting no success. The solution is:
sudo apachectl graceful
php app/console doctrine:cache:clear-query --env=prod
Clearing ALL Query cache entries
php app/console doctrine:cache:clear-result --env=prod
Clearing ALL Result cache entries
php app/console doctrine:cache:clear-metadata --env=prod
Clearing ALL Metadata cache entries
php app/console cache:clear --env=prod
Clearing the cache for the prod environment with debug false
And don't forget to put --env=prod to your commands
"Old but still happens"
If none of the solutions mentioned above worked
try to delete the Entity cache file manually :
(e.g Entity costumer cache file path should be this one)
projectdirectory\projectname\var\cache{dev or prod}\jms_serializer\Tete-AdminBundle-Entity-Customer.cache.php
I had similar problem, I just used doctrine:mapping:import and that was it.
Cheers
We had the same issue and in our case (Nginx), the restart of Nginx didn't help.
But restart of memcache was the right solution:
sudo service memcached restart
Related
I have a Symfony 4.1 app, where I use Doctrine and want to setup Redis cache for Doctrine.
Here is a part of composer.json
"snc/redis-bundle": "^2.1",
"symfony/doctrine-bridge": "^4.1",
"symfony/proxy-manager-bridge": "^4.1",
Here is yml config file:
snc_redis:
clients:
doctrine_cache:
type: phpredis
alias: doctrine_cache
dsn: '%my_dsn%'
doctrine:
metadata_cache:
client: doctrine_cache
entity_manager: default
The problem is: on the very first time when Symfony tries to generate cache for all DI containers, it initializes Redis connection. This means for example when I run any console command, it tries to connect to redis. Example:
// very first command after git clone and composer install
php bin/console about
Output:
In PhpredisClientFactory.php line 64:
php_network_getaddresses: getaddrinfo failed: No such host is known.
I expect that Redis cache service will be initialized lazily, otherwise I cannot run other build commands on independent (non having Redis) environment.
Can someone advise please?
If this happens after composer install then you might have composer run the default commands:
- "post-install-cmd"
- "post-update-cmd"
Try to remove them and add see if the Redis works... If it works then add a script to your deployment entrypoint to run them at the end.
PS: pay attention to doctrine and Redis if you are using migrations: then you should also clear doctrine cache.
I have developed an application in Symfony 4. The application works perfectly in localhost, with the command php -S 127.0.0.1:8000 -t public I see the application in localhost: 8000, but if I access localhost / nameproject / public I have a page white. I ran the commands composer install --no - dev --optimize - autoloader, export APP_ENV = prod, php bin / console cache: clear --env = prod --no - debug and composer require symfony / apache - pack. Can someone help me?
I found the error, with php -v I return the 7.1.14 version, but with phpinfo () I found that I have in the php php version 5.6! I hope my experience can be useful to someone!
creating symfony project
composer create-project symfony/skeleton cars
cd cars
php -S 127.0.0.1:8000 public/index.php
composer require annotations
composer require twig
composer require asset
Creating Page
public/image/seta.png
templates/number.html.twig
<img src="{{asset('image/seta.png')}}">
src/Controller/CarController.php
/**
* #Route("/")
*/
public function number()
{
return $this->render('number.html.twig');
}
Why does browser show:
Symfony Exception > ResourceNotFoundException > NotFoundHttpException
No route found for "GET /image/seta.png" (from "http://localhost:8000/")
(Web page doesn't show seta.png)
The issue you're having is that the browser can't find the image, as in the path you have given it doesn't exist or isn't accessible to the client. That's what your error is indicating.
You need to confirm that you can access the image through your browser first. If you can't, then I would suggest you start to look at it's location and whether the path you're using corresponds to it's location.
If you're sure the file path is fine and the image exists and that it's named correctly corresponding to what you're calling it, you should then check the file and folder permissions where the image is located so it's accessible.
Please check the HTML, this code rendered.
<img src="{{asset('image/seta.png')}}">
change
php -S 127.0.0.1:8000 public/index.php
to
php -S 127.0.0.1:8000 -t public
Ronald2g is right, you can also try with the web server bundle:
composer require server --dev
and:
php bin/console server:start
Not sure if it can help you, but this might help others having a similar issue.
I had the same issue when I was mistakenly using an internal port number (port 42595 in the example below) given in the command line feedback, instead of port 8000:
$ symfony server:start --no-tls
Feb 25 12:25:30 |DEBUG| PHP Reloading PHP versions
Feb 25 12:25:31 |DEBUG| PHP Using PHP version 7.4.2 (from default version in $PATH)
Feb 25 12:25:31 |INFO | PHP listening path="/usr/bin/php7.4" php="7.4.2" port=42595
Feb 25 12:25:31 |DEBUG| PHP started
Feb 25 12:25:31 |DEBUG| PHP PHP 7.4.2 Development Server (http://127.0.0.1:42595) started
[OK] Web server listening on 8000 http://127.0.0.1:8000 (PHP CLI 7.4.2)
I developed a little management application with Symfony. It works a lot on local. I put it all on my webserver (called Planethoster), and I've got the following message when I try to login in my application using app.php:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: NO)
But in my parameters.yml file, I have not put the root user, it's another standard user that can only SIUD. I believe that app.php does not load my parameters.yml or config.yml file.
The last but not the least, I can log in using app_dev.php. It works but not with app.php.
Verify your Database settings in app/config_prod.yml for production use.
clear your cache by php app/console cache:clear --env=prod
I have two database connections in config.yml and two entity managers. Each are tied to a bundle.
The issue that I'm having is running unit tests, which start by creating a blank db and loading in data. It's creating both databases but i'm getting both sets of tables in each database, instead of one set of entities in one db and one in the other. Since two db connections isn't incredibly common, I'm having trouble finding some help on this.
doctrine:
dbal:
default_connection: default
...
connections:
default:
(conectioninfo)
seconddb:
(connectioninfo)
orm:
default_entity_manager: default
auto_generate_proxy_classes: "%kernel.debug%"
entity_managers:
default:
connection: default
mappings:
MycompanyCoreBundle: ~
seconddb:
connection: seconddb
mappings:
MycomanySecondBundle: ~
When running unit tests, the lines I have are:
php app/console doctrine:database:drop --force --env=test --connection=default
php app/console doctrine:database:create --env=test --connection=default
php app/console doctrine:schema:drop --force --no-interaction --env=test --em=default
php app/console doctrine:schema:update --force --no-interaction --env=test --em=default
php app/console doctrine:database:drop --force --env=test --connection=seconddb
php app/console doctrine:database:create --env=test --connection=seconddb
php app/console doctrine:schema:drop --force --no-interaction --env=test --em=seconddb
php app/console doctrine:schema:update --force --no-interaction --env=test --em=seconddb
When running all this, the output is
Successfully deleted cache entries.
Dropping database schema...
Database schema dropped successfully!
Updating database schema...
Database schema updated successfully! "91" queries were executed
The problem is that those 91 queries are a combination of both Entity folders in the two bundles. I'm missing somewhere to point them separately so they go into their respective databases.
I found the answer to this eventually. There isn't a way to specify a database for a Migration, so you basically have to run Migration twice on EM and then test for the db connection.
Within each migration file, you put in a line to ignore it if it's not the correct one. Thus, some files have
$this->skipIf( $this->connection->getDatabase() != 'dbone', 'Skipping database.' );
and others have
$this->skipIf( $this->connection->getDatabase() != 'dbtwo', 'Skipping database.' );
Then when you run these commands:
doctrine:migrations:migrate --em="default"
doctrine:migrations:migrate --em="orm"
Both will cycle through all your migration files but the ones that don't apply to that situation will be ignored.