Sonata admin styles/scripts not loaded with error 403 - symfony

i have a problem with Sonata Admin bundle. (Symfony version 3.3.11, Sonataadmin 3.24) On localhost everything works fine, but on server all styles and scripts placed in web/bundles/sonataadmin and web/bundles/sonatacore directories is not loaded with error 403. Permission of directories is 777 for folders, 644 for files. How can i fix this problem? Thanks.

Can you try following:
php bin/console cache:clear --env=prod --no-debug
php bin/console assets:install --symlink --env=prod --no-debug
php bin/console assetic:dump --env=prod --no-debug
sudo setfacl -R -m u:www-data:rX path_to_your_project
Do you have result?

I solved this problem by running next command:
php bin/console assets:install

Related

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

Twig_Error_Loader - directory does not exist

I have this error when deleteing cache.
sudo php app/console cache:clear --env=prod --no-debug
[Twig_Error_Loader]
The "/Users/whitebear/CodingWorks/httproot/myapp/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/Resources/views" directory does not exist ("/Use
rs/whitebear/CodingWorks/httproot/myapp/vendor/symfony/swiftmailer-bundle/Symfony/Bundle/SwiftmailerBundle/Resources/views").
I deleted all vendor/* and reinstalled by composer, but this error continues.
sudo php app/console cache:clear
This command shows no error.
Remove cache manually - rm -rf var/cache/*
Clean spooled emails rm -rf SPOOL_DIRECTORY/*, by default rm -rf var/spool/*
Both from project root directory.

Error during composer install --no-dev option in ElasticBeanstalk with Symfony 2

I am deploying Symfony 2 app in ElasticBeanstalk but when I run this I get an error saying
ERROR: Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle class not found.
I have this config.
container_commands:
110-remove-pg:
command: "yum remove -y php56-pgsql"
120-install-pglib:
command: "yum install -y postgresql94-libs"
130-install-pg:
command: "yum install -y php56-pgsql"
140-clear-folder:
command: "rm -rf var/cache/* var/logs/* var/sessions/*"
150-folder-config:
command: "source .ebextensions/bin/folder.sh"
160-pre-cache-clear:
command: "php bin/console cache:clear --env=prod --no-debug"
170-run-export:
command: "export SYMFONY_ENV=prod"
180-composer-install-no-dev:
command: "composer.phar install --no-dev --optimize-autoloader"
190-post-cache-clear:
command: "php bin/console cache:clear --env=prod --no-debug"
200-assets-dump:
command: "php bin/console assetic:dump --env=prod --no-debug"
210-remove-dev-app:
command: "rm web/app_dev.php"
Seems like it is still triggering DEV option. If I remove --no-dev option it works fine. But I do not want DEV packages. Is there anyway to resolve this issue.
Alright I found the solution of this problem. Apparently you need to put
SYMFONY_ENV=prod
In environment variables list for this to work.

Assetic Dump Cannot Locate File

I am currently trying to move my Symfony App from dev to prod. I am running this commandline script to compile my js and css files:
php app/console assetic:dump --watch;
When I do so, I get the following error:
The source file "/Applications/XAMPP/xamppfiles/htdocs/symfonydev/app/../web/assets/js/js/bootstrap/" does not exist.
I have also run this script:
php app/console assetic:dump --env=prod --no-debug
It gives me a whole other bunch of issues which I will put in another post question.
I have run these scripts to see I can find the file that this is happening in:
find . -name '*.html.twig' -exec grep -li 'assets/js/js/bootstrap*' {} \;
find . -name '*.html.twig' -exec grep -li 'js/js/bootstrap*' {} \;
find . -name '*.html.twig' -exec grep -li 'js/bootstrap*' {} \;
They return no values :(
I cannot compile my js files because I keep getting this error. How in the world do I proceed in moving this Symfony2 app! Please assist if you could.
Thanks!
I found the issue, I had some Bundles in Symfony that were incorrectly configured. Then I found a rouge directory that I made waaaaaaay back when and removed it. Once I did that and ran
sudo rm -rf app/cache/* app/logs/*
and then ran
php app/console assetic:dump --env=prod --no-debug
all was well. Thanks for your feedback everyone!

InvalidArgument exception with symfony2

When I do app/console cache:clear --env=prod --no-warmup in the console i'm getting the next error:
[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
The service definition "security.access.decision_manager" does not exist.
I'm using Symfony2 v2.2.8
I don't use the security.access.decision_manager in my own bundles..
I've searched for security.access.decision_manager in my project but could not find anything from my bundles...
I there also a way to get a backtrace in the console?
The strange thing is, if I do app/console cache:clear --env=dev --no-warmup -v It works fine! And if I do app/console cache:clear --env=prod --no-warmup -v I get that error again..
After debugging hours I've fount the problem!
I was missing the security include in the config_prod.yml
imports:
- { resource: config.yml }
- { resource: parameters_prod.yml }
- { resource: security_prod.yml } <-- The missing one
try next:
rm -rf app/cache/prod/*
rm -rf app/cache/dev/*

Resources