For designers, Symfony2 has been a welcome change from those old flat PHP files. Twig is beautiful, the framework separates the code from the layout, and we no longer have to find our way through lines of PHP code. But if you are a designer working on a symfony project for the first time, these are a few tips that can help you get up and running quickly.
How do I disable the toolbar at the bottom of the page?
The toolbar at the bottom of the page is useful for developers but a hinderance to designers (especially if you are developing mobile apps). Not only does it cover your footer, but it also slows the page down. Since we don’t need it, most designers will want to get rid of it. To do this just edit: config/config_dev.yml and set the web_profiler to false:
config_dev.yml -> web_profiler: toolbar: false
Symfony has a lot of moving parts. Learning what the errors are and how to fix them is a useful skill to have.
You need to run:
Assetic is the part of Symfony that compiles LESS files, combines and compress CSS and JS files, among other things. Sometimes when you download new files the cache needs to be recreated. Running the above command does this. Another useful way to use this command is:
./app/console assetic:dump -watch
This automatically recompiles all the css and js every time you modify a css and js file.
Symfony requires a series of libraries to run. Every so often these libraries get updated and you are required to update them on your local server as well. If your libraries are not updated, you will see an error like the one above.
To fix this open your terminal, go navigate to the root of your project and run:
When you do ./bin/vendors install you will download all the latest libraries your application requires to function correctly. Once you run this command you should see a log printing out listing all the libraries that are being installed. Check that log to make sure you don’t have any permissions errors. In case you do run this command and enter your administrator password on prompt:
sudo ./bin/vendors install
Symptom: Blank page
90% of the time when you get a blank page it’s a permission issue. Symfony requires app/cache and app/logs directories to be writable both by the web server and the command line user. Fortunately fixing these is simple enough. In your terminal go to the root directory of your project and type:
rm -rf app/cache/* rm -rf app/logs/* sudo chmod +a "www-data allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
If you are on a Mac and you are using Apache web server that comes with Mac OSX, replace www-data with _www in the above command.
Have more tips? Add them to the comments below!