Docker/Symfony5.2 Cache failed to opening required - symfony

I have the following error when using prod env :
Uncaught PHP Exception Symfony\Component\ErrorHandler\Error\FatalError: "Compile Error: require(): Failed opening required '/app/var/cache/prod/doctrine/orm/Proxies/__CG__AppEntitySecurityFrontendUser.php' (include_path='.:/usr/local/lib/php')" at /app/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php line 204 {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Compile Error: require(): Failed opening required '/app/var/cache/prod/doctrine/orm/Proxies/__CG__AppEntitySecurityFrontendUser.php' (include_path='.:/usr/local/lib/php') at /app/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php:204)"} []
I already tryed:
edit all files with auto_generate_proxy_classes to true
rm -rf /app/cache + chmod 777
app/console cache:warmup --env=prod
this error does not appear with a dev env

Related

undefined symbol: lua_rotate

I had done below steps,
downloaded lua-cjson-2.1.0.7 from this repo, Not really know what went wrong. can anybody know whats going on and how to resolve this?
make install
mkdir -p /usr/local/lib/lua/5.1
rm -f /usr/local/lib/lua/5.1/cjson.so
cp cjson.so /usr/local/lib/lua/5.1
chmod 755 /usr/local/lib/lua/5.1/cjson.so
Then,
sudo systemctl restart nginx.service
Error:
2020/02/19 06:59:52 [error] 29524#29524: *1 lua entry thread aborted: runtime error: error loading module 'cjson' from file '/usr/local/lib/lua/5.1/cjson.so':
/usr/local/lib/lua/5.1/cjson.so: undefined symbol: lua_rotate
stack traceback:
coroutine 0:
[C]: in function 'require'
nginx.conf has below :
lua_package_path "/usr/local/lib/lua/?.lua;;";
And
/usr/bin/lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio

How to use app/console command line for Symfony on shared servers?

How to use app/console command line on shared servers?
When I try to flush de cache for example with:
app/console cache:clear -e prod;
I keep getting this kind of errors:
PHP Parse error: syntax error, unexpected 'class' (T_CLASS),
expecting identifier (T_STRING) in
/home/clients/f61b2e8462ca91d597e79838efafc0d1/krown/vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php
on line 62
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting
identifier (T_STRING) in
/home/clients/f61b2e8462ca91d597e79838efafc0d1/krown/vendor/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php
on line 62
[Symfony\Component\Debug\Exception\FatalErrorException]
Parse Error: syntax error, unexpected 'class' (T_CLASS), expecting
identifier (T_STRING)
In my dedicated server I dont' have this kind of error. The same PHP version (7.1) is installed in both servers.
I was able to solve my issue by forcing the PHP version appending it to all my "app/console" queries, for example:
php-7.1 app/console cache:clear -e prod
php-7.1 app/console cache:clear -e dev
php-7.1 app/console doctrine:generate:entity
php-7.1 app/console doctrine:generate:entities Front
php-7.1 app/console doctrine:schema:update --dump-sql
php-7.1 app/console doctrine:schema:update --force

Can't activate Pro SNAP WordPress plugin

Activation process after entering the activation key is lasting forever with the message "Your plugin will be automatically upgraded."
I got php7 on my server.
I've found an error message in my php error log file:
FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function utf8_decode() in ..."
Then I've fixed it:
$ sudo apt-get install php7.1-xml
$ sudo apt-get install php7.1-curl
After that I could activate my SNAP PRO WordPress plugin.

How to run a Symfony command from Heroku's Scheduler

I've configured Heroku's Scheduler to run a Symfony 2 command:
bash app/console myapp:send:confirmations --verbose
And set it to be run each 10 minutes.
But, in the logs I see those messages:
2015-09-10T13:01:25.313711+00:00 heroku[api]: Starting process with command `bash app/console myapp:send:confirmations` by scheduler#addons.heroku.com
2015-09-10T13:01:44.151426+00:00 heroku[scheduler.7629]: Starting process with command `bash app/console myapp:send:confirmations --verbose`
2015-09-10T13:01:44.811500+00:00 heroku[scheduler.7629]: State changed from starting to up
2015-09-10T13:01:45.565021+00:00 app[scheduler.7629]: app/console: line 2: ?php: No such file or directory
2015-09-10T13:01:45.565093+00:00 app[scheduler.7629]: app/console: line 19: unexpected EOF while looking for matching `''
2015-09-10T13:01:45.565096+00:00 app[scheduler.7629]: app/console: line 28: syntax error: unexpected end of file
2015-09-10T13:01:46.291606+00:00 heroku[scheduler.7629]: State changed from up to complete
2015-09-10T13:01:46.278800+00:00 heroku[scheduler.7629]: Process exited with status 2
Those are the three relevant that are confusing me:
2015-09-10T13:01:45.565021+00:00 app[scheduler.7629]: app/console: line 2: ?php: No such file or directory
2015-09-10T13:01:45.565093+00:00 app[scheduler.7629]: app/console: line 19: unexpected EOF while looking for matching `''
2015-09-10T13:01:45.565096+00:00 app[scheduler.7629]: app/console: line 28: syntax error: unexpected end of file
I'm a bit confused: the file app/console seems not exist, but then the script encounters an unexpected EOF (but the file doesn't exist o.O) and then an unexpected end of file (isn't this the same thing as the message immediatley before?
What am I doing wrong?
Use php instead of bash to launch the console:
php app/console myapp:send:confirmations --verbose
I have the same behaviour (crash) on Ubuntu 15.04:
$ bash app/console
app/console: line 2: ?php: No such file or directory
app/console: line 18: unexpected EOF while looking for matching `''
app/console: line 23: syntax error: unexpected end of file
$ php app/console -v
Symfony version 2.7.4 - app/prod
...
It seems that the shebang from the start of app/console is ignored and the PHP interpreter is not called:
#!/usr/bin/env php
<?php
....
Here are explanations from Aaron Copley:
It's not executable
Run the binary with absolute or relative path
So if you mark the file as executable and launch the script with relative path, the PHP interpreter will be called:
$ chmod +x app/console
$ ./app/console -v
Symfony version 2.7.4 - app/prod

getenv('SYMFONY_ENV') is empty in app/console from composer install, but OK elsewhere

To deploy my Symfony app on production I run the following command in a bash script:
php composer.phar install --no-dev --optimize-autoloader
And I got the following error :
Script
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
handling the post-install-cmd event terminated with an exception
An error occurred when executing the "'cache:clear --no-warmup'" command.
This is because getenv('SYMFONY_ENV') in the app/console returns an empty value, while executing the commands from composer.json post-install-cmd. Therefore the $env value is not set to prod but to dev (default one).
However, the SYMFONY_ENV value is ok.
In the terminal, if I run:
printenv SYMFONY_ENV
It prints prod
If I run:
php -r "print_r(getenv('SYMFONY_ENV'));"
It prints prod
What I am missing or doing wrong ?
I just realized that I was running
sudo php composer.phar install --no-dev --optimize-autoloader
instead of
php composer.phar install --no-dev --optimize-autoloader
In my case (ubuntu 14.04), I had defined SYMFONY_ENV in /etc/environment and I thought it was accessible for all users, but it's not the case for sudo. I solved my problem running my command without sudo (because it had no reasons to be).
Another solution could be to run sudo -E php ... to preserve the user environment as suggested here : https://askubuntu.com/questions/161924/how-do-i-set-persistent-environment-variables-for-root

Resources