Question

I found the console and run it like this:

root@valugi-laptop:/var/www/sandbox/hello# php console
Symfony version 2.0.0-DEV - hello

Usage:
  Symfony [options] command [arguments]

Options:
  --help      -h  Display this help message.
  --quiet     -q  Do not output any message.
  --verbose   -v  Increase verbosity of messages.
  --version   -V  Display this program version.
  --color     -c  Force ANSI color output.
  --no-interaction -n  Do not ask any interactive question.
  --shell     -s  Launch the shell.

Available commands:
  help               Displays help for a command (?)
  list               Lists commands
assets
  :install           
bundle
  :pharize           
container
  :graphviz          
doctrine
  :generate-proxies  
init
  :application       
  :bundle            
router
  :debug             Displays current routes for an application
  :dump-apache       

But I cannot run any of those commands. I am trying like this:

php console Symfony -h

But I get

[InvalidArgumentException]         
Command "Symfony" is not defined.  

Any suggestions?

Was it helpful?

Solution 3

Find myself an answer.

root@valugi-laptop:/var/www/sandbox/hello# chmod 777 /var/www/sandbox/src/Bundle
root@valugi-laptop:/var/www/sandbox/hello# php console init:bundle "Bundle\\ValugiBundle"

OTHER TIPS

Console is used like this: $ php app/console [command name]

From app root: ./app/console --shell

Use the following to create a new symfony2 bundle:

php app/console init:bundle Acme\\DemoBundle src

That will create a new bundle in src with this directory structure:

src/Acme/DemoBundle/
                    AcmeDemoBundle.php
                    Controller/
                               DefaultController.php
                    Resources/
                              config/
                                     routing.yml
                              views/
                                    Default/
                                            index.html.twig

and the namespace will be Acme\DemoBundle.

I put together a bash script to help with this by allowing the CLI tool to be easily accessible from everywhere in your project. Download it, make it executable and put it in your PATH (/usr/local/bin/ for example).

Then you don't need to be in the root of your project to reach the CLI tool. Just fire away sf <command>. It works for both Symfony 1.3/1.4 and Symfony2.

I tried to vote down your own answer but I don't have enough rep for it!

-

Sergi and ok answered you accurately but I'll expand in case anyone reading this is confused as you are.

You tought you needed to use "php console Symfony" because you dont make folder names easy on yourself.

I like working from my home folder. I always start there whenever I log in so I create myself a folder in my home like:
~/web/sandbox.sf2

then you could use symbolic links to /var/www like:
sudo ln -s ~/web/sandbox.sf2/home/myusername/web/sandbox.sf2

so when you work on your files, you will know you already are in a symfony2 project. (and I tought too it was weird to use it like that at first, but I got used to it, and used Tobias same kind of answer, a bin script to wrap app/console as sf2 init:bundle and sf list for example)

You obviously also have user permission issues (http://google.com/search?q=linux+permissions, second result looks good).

Make sure you as a user/group can edit your files and folders. php app/console runs as the user you used (root in this case). Also make sure the apache user/group can read your files.

-

And please, dont use root account to chmod 777 -R when something isn't working. Test simple ownership permission, its easy and a needed concept if you are exposing a web server to the world wide web.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top