symfony2 assets in changed web folder - symfony

I'm using Symfony2 in my project and I changed web root ditectory. I followed instructions on this page http://symfony.com/doc/current/cookbook/configuration/override_dir_structure.html. Now my project structure looks like this:
/frontend - the new web root dir
/myproject - the project dir
Then i'm installed and dumped assets
php app/console assets:dump
php app/console assetic:install ../frontend --symlink
Most things works fine. But the problem is that I can't acces to any asset in /bundles directory, Symfony returns error
No route found for "GET /bundles/..."
But I can see my assets in this directory in explorer (symlinks created correctly).

Is your web server configured to follow symlinks? Without knowing which web server you are using, as an example in apache you need to set the FollowSymLinks option. Alternatively, remove the symlink option when doing assets:install.
Also, it's probably just a typo, but you've got the commands for installing assets and dumping assetic a bit muddled in your question - should be something like this:
php app/console assets:install --symlink ../frontend
php app/console assetic:dump -e dev

Related

symfony assetic dir. does not exist

I've dumped assets using the folling command:
php app/console assetic:dump
I've got a Runtime exception:
The source file "c:\EasyPHP\data\localweb\projects\symfony\src\LV\IndexBundle/Resources/public/images/" does not exist.
It seems to me strange that:
the / goes to \Resources only, after it is /
the directory images does exist in public
no CSS work. I even tried internal CSS in layout.html.twig. Nothing changes.
OS: Windows 10
Try to remove vendors and re composer install, clear cache directory.
If problem isn't solved after that, please share your config.yml here

How to get assetic to update assets in dev enviroment in symfony2?

I have the issue that my assets, e.g. my sass and javascript, did not recompile on file modification. I installed I accessed them via symlink option and access the dev environment via localhost:8000. I have to manually call /app/console assetic:dump for them to update.
How do I get assetic to watch for file modification?
You can also use
php app/console assetic:dump --watch
If you want to watch for file modifications. This will re-run assetic:dump in the background automatically for you.
And yes dont forget if you use dev then access your site via app_dev.php
And small note... when you use production environment then make sure you execute assetic:dump with --env=prod (without --watch as well)
I realized I have to access the dev page with app_dev.php:
localhost:8000/app_dev.php/
Try to execute:
php app/console assetic:dump --env=dev

Symfony 2.2 Deployment Questions

Because of an other problem on my server, I tried to setup a real new project and did this (localhost with xampp on windows):
installed curl
loader composer like told in docs
loader vendors like told in docs
merged app/config-folder
copied src-folder
copied web/bundles/myBundle-folder
After that, I tried the deployment-steps documentation. I skipped uploading the files and editing parameter.yml (it's already configured for localhost).
Than I am running into trouble doing 'B) Update your vendors':
php composer.phar install --optimize-autoloader
This steps remove all my files from the web\bundles\myBundle-folder.
Do I have to tell composer about my bundle? I first thought, that I have to store them somewhere else, but this thread tells me, that I am right?!
The thread you are mentioning is from symfony 1, but you are installing a symfony 2 application.
In web/bundles are your assets installed (css, javascript and images).
Your bundles which will be installed via composer are in your vendors folder.
And your own bundles should be in the src folder.
I think this is a good start to have a look at where to store your files.
Your css, js and images should be stored in a bundle, e.g.:
src/AcmeDemoBundle/Resources/public/css
src/AcmeDemoBundle/Resources/public/js
src/AcmeDemoBundle/Resources/public/images
And then you can install your assets with php app/console assets:install web and they will be pushed into the web/bundles folder.

symfony2 assets:install output directory

I am trying to change the default "web" directory of symfony to something else for example public_html.
I got most of it working by following the manual here -> http://symfony.com/doc/master/cookbook/configuration/override_dir_structure.html
Very last part of that document explains how to change assetic so that assetic:dump will output to the correct directory, so that works, and the website also works.
However the document doesn't seem to explain how to change the output directory of the assets:install command.
When i run this command it still outputs to the web directory.
Does anybody know how to change this ?
assets:install requires a parameter telling where to install the assets:
app/console assets:install path
Just provide your path instead of web.
You can set a path parameter to assets:install
But I think in some case better not overriding the directory structure, preferably making a symlink to the web dir.

Symfony2 what to do when deploying manually?

Since i can't find any useful information on Symfony2 website i'm asking here. What should be done when manually deploying a Symfony2 project? As far i understand:
Edit app/config/paramenters.ini to meet server paramenters
Update vendors to the latest version: php bin/vendors update
Install database with php app/console doctrine:database:create then tables with php app/console doctrine:schema:update --force and eventually load fixtures: php app/console doctrine:fixtures:load
Dump and install assets/assetics: php app/console assets:install --symlink web as long as php app/console assetic:dump --env=prod --no-debug
Symlink index.php to web/app.php, assuming that all files from Symfony2 distribution are in the root of the web server
Remove web/app_dev.php (is this really necessary?)
should app/config/paramenters.ini left untouched? What about security concerns?
Am i right? Thanks for helping. I think that Symfony2 documentation should cover this too.
EDIT: virtual host example:
<VirtualHost *:80>
ServerName symfony.local
DocumentRoot "C:/www/Symfony2/web"
DirectoryIndex app.php
<Directory "C:/www/Symfony2/web">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
Only two things I wouldn't do is:
Symlink index.php to web/app.php, assuming that all files from
Symfony2 distribution are in the root of the web server
Remove web/app_dev.php (is this really necessary?)
The thing with the symlink might be ok, but I prefer to link the webroot directory with the web directory of symfony2.
Second thing is, you don't have to remove app_dev.php, because it can only be run from localhost (it checks the IP). So no need to remove it, and I personally sometimes want to see debug info on the webpage (maybe not best way), and than I just add my own IP to app_dev (and remove it afterwards).
Yes. That is all. And also you don't need web/app_dev.php in prod environment.
Moreover, web folder should be document root and run app.php
I think you should put DirectoryIndex app.php inside <Directory></Directory>

Resources