problems with symfony2 images (403 forbidden) - php

I uploaded symfony2 project to servergrove.com and after this created assets using
php app/console assets:install --symlink web
and also
php app/console assetic:dump --env=prod --no-debug
After these steps I can't access images in the web/bundles folder, I get a "403 forbidden" error.
The URL to my site is http://myserjtankian.com.preview-sg111.servergrove.com/

You may fix that using this command line (without --symlink web arg) :
php app/console assets:install
This will install assets as hard copies.
Hope it's helpful
Best regard

Related

projet symfony dont display css and js and pictures

I created one project in symfony 2 I send it to my company but the project not working properly no fils css, no file js no pictures.
I'need my my laptop it works correctly.
So i connected remotly to my company
I excuted this command
php app/console assetic:dump
but I have this problem
There are no commands defined in the "assetic" namespace.
Did you mean this?
assets
I don't know why I have this problem with this command. But
php app/console assets:install it works correctly
Thanks stack overflow
In the documentation is written that be used with:
php app/console assetic:dump --env=prod --no-debug
maybe the directory seperator like \ and no /
https://symfony.com/doc/2.8/assetic/asset_management.html#dumping-asset-files-in-the-prod-environment
this command belongs to this bundle
https://github.com/symfony/assetic-bundle
I think above bundle is not installed.
check your composer.json or vendor folder.

AdminLTE + symfony2 -> Unable to find file

I tried to install the adminlte bundle but with no luck. Ive always get:
Unable to find file "#AvanzuAdminThemeBundle/Resources/public/vendor/modernizr/modernizr.js" in . (which is being imported from "app\cache\dev/assetic/routing.yml").
things ive done:
Added this to the composer.json
{
"require": {
"avanzu/admin-theme-bundle": "~1.3"
}
}
then php composer.phar require avanzu/admin-theme-bundle
added new Avanzu\AdminThemeBundle\AvanzuAdminThemeBundle(), to the AppKernel
Copy everything with app/console assets:install --symlink
Then went to the base.html.twig and added
{% extends 'AvanzuAdminThemeBundle:layout:base-layout.html.twig' %}
If i start the server i get those error. The files are located here:
./vendor/avanzu/admin-theme-bundle/Resources/public/static/dev/scripts/modernizr.js
./vendor/avanzu/admin-theme-bundle/Resources/public/static/prod/scripts/modernizr.js
./web/bundles/avanzuadmintheme/static/dev/scripts/modernizr.js
./web/bundles/avanzuadmintheme/static/prod/scripts/modernizr.js
Whats my fault? Thanks!
You have to fetch all the vendors as well :
php app/console avanzu:admin:fetch-vendor
Here is the documentation.
Good luck!
Run the following command to create all the symlinks
php bin/console assets:install --symlink
OR
php app/console assets:install --symlink

Symfony2.7.1 fresh installation. Failed to load resource

Symfony2 developers:
Recently, I am planning to get familiar with Symfony2, using it as api project. Current version is v2.7.1.
I already have apache installed as my local environment. So the installation root directory is:
//localhost/symfony
So I followed official guide to install it. Everything looks fine after installation. But when I view the page in development environment (app_dev.php).
//localhost/symfony/web/app_dev.php
Page content display as expected, but not styled. Then I open console and find some 404 response as follows:
Failed to load resource
//localhost/symfony/web/bundles/framework/css/structure.css
//localhost/symfony/web/bundles/framework/css/body.css
//localhost/symfony/web/bundles/framework/css/exception.css
//localhost/symfony/web/app_dev.php
//localhost/symfony/web/bundles/framework/css/structure.css
//localhost/symfony/web/bundles/framework/css/body.css
//localhost/symfony/web/bundles/framework/css/exception.css
I looked into project/web/bundles directory, found nothing inside but two empty file.
framework and sensiodistribution.
Fresh installation without any config change. I got this problem. Could you guys give some explanation why it occurs. Otherwise I didn't get the full package?
Do I miss those files inside project/web/bundles?
If the case in which i missed those file. So could you send me an archive file on current version 2.7.1?
You must run the command app/console assets:install to generate symlinks (or files) in /web/bundles
If these files exists then you probably have problem with URL Rewriting check your .htaccess or configure your host. You can also use command php app/console server:start and check there if it works
You can run composer install to install all necessary bundles and libraries and probably composer.json has defined postinstall commands.
If you use assetic then you can try to run php app/console assetic:dump more on http://symfony.com/doc/current/cookbook/assetic/asset_management.html
In Symfony 2.6 you have new asset manager read more on http://symfony.com/blog/new-in-symfony-2-6-smarter-assets-install-command
php app/console assets:install or php app/console assets:install --symlink
for Symfony 3.x the directory changed from app to bin so commands are:
php bin/console assets:install or php bin/console assets:install --symlink
Since I landed here from a Symfony 3 search this might be useful for Symfony 3 users having the same problem
Run php bin/console assets:install at the project root

Steps for going live - Symfony2

I've been working on my website for some time now and I am now ready to push this brand new project to live.
I have already already read this link on Symfony2 with regards to what should be done, but I still think it is missing some details. For example, it talks nothing about some of the commands that I run to get the site to work on live.
Currently this is what I would like to do to get this to work on live:
php composer.phar install --no-dev --optimize-autoloader --no-scripts
rm -rf app/cache/*
php app/console assetic:dump --env=prod --no-debug
php app/console assets:install web --symlink --env=prod
Is there anything else that needs to be done, for example, I don't want live to be able to execute my fixtures, nor do I want any users to be able to go to www.mysite.com/app_dev.php
Check out How to deploy a Symfony2 application.
Refer to link above. The typical steps taken while deploying a Symfony2 application include:
Upload your modified code to the live server;
Update your vendor dependencies (typically done via Composer, and may be done before uploading);
Running database migrations or similar tasks to update any changed data structures;
Clearing (and perhaps more importantly, warming up) your cache.
Common Post-Deployment Tasks
Configure your app/config/parameters.yml file
Update your vendors
$ php composer.phar install --no-dev --optimize-autoloader
Clear your Symfony cache
$ php app/console cache:clear --env=prod --no-debug
Dump your Assetic assets
$ php app/console assetic:dump --env=prod --no-debug
Other things!
There may be lots of other things that you need to do, depending on your setup:
Running any database migrations
Clearing your APC cache
Running assets:install (taken care of already in composer.phar install)
Add/edit CRON jobs
Pushing assets to a CDN
...
take a look at capifony (https://github.com/everzet/capifony). Unfortunately the Website (http://capifony.org) is currently down..
The best solution to me is to have your project in a versionning system like git or svn without the vendors dir of course ...
This way, your simply have to do :
1) git clone your project into the prod dir
2) php composer.phar install to install your vendors
2b) create the mysql user with correct login and password according to your parameters.yml
3) php app/console doctrine:database:create to create your database with the credentials you set up in mysql
4) php app/console doctrine:schema:update --force to perform the database tables creation
5) testing the project :)
If you are not using a versionning system just upload your project to your server with an ftp software without the vendors directory ( it will be feeded by step 2) then perform 3rd , 4th and 5th steps !
you now should be able to reach you project through you domain url .

Symfony 2 - switching from app_dev to app

i didnt understand how assets:install works..
When i run php app/console assets:install web it copy these bundles.
Installing assets for Symfony\Bundle\FrameworkBundle into web/bundles/framework
Installing assets for Sensio\Bundle\DistributionBundle into web/bundles/sensiodistribution
I want to copy my project to app.php, the project is in /src/Dproc/..bundles..
How should i do that?
Switching to the prod environment:
php app/console cache:clear --env=prod

Categories