Code snippets for symfony 1.x


Refine Tags

Snippets tagged "web"

Automatically create symlinks to plugins' web directories

I use this small bash script to automatically detect /plugins/*/web directories and symlink them in /web folder.

This is particularly useful for SVN installations of plugins, which do not handle this for you.

if [ ! -d web -o ! -d plugins ]
  echo "You must be in a Symfony project root"
  exit 1
# Create links from /web directory
cd web
# List plugins' web directories
ls -d "../plugins/*/web" | while read plugin_web
  plugin=$(basename $(dirname $plugin_web))
  if [ ! -d $plugin ]
    ln -f -s -v $plugin_web $plugin
# Go back to project's root
cd ..

You could use a "compact" version as an alias ;)

alias ln_plugins_web="cd web && ls ../plugins/*/web | while read plugin_web; do plugin=$(basename $(dirname $plugin_web)); if [ ! -d $plugin ]; then ln -f -s -v $plugin_web $plugin; fi; done; cd .."

Note : if your bash installation does not provide "basename" and "dirname" commands, you can add them manually with those aliases

function dirname() {
  echo "$1" | sed 's/\/[^\/]*\(\/*\)\?$//';
function basename() {
  echo "$1" | sed 's/^.*\/\([^\/]\+\)\/*$/\1/
by Nicolas Chambrier on 2008-03-23, tagged bash  linux  plugins  web