The Symfony CLI
-
Upload
sarah-el-atm -
Category
Technology
-
view
98 -
download
4
Transcript of The Symfony CLI
THE SYMFONY CLIDIGITAL POETS SOCIETY - SYMFONY2 MEETUP (MELBOURNE)
Tom Corrigan / @thetommygnr
ABOUT MEDeveloping Symfony apps since 2.0Lead Developer of Co-Founder of Attended Symfony Live 2012 in Paris
crscertus.com.aurostercloud.com
THE CONSOLE ITSELF$ app/consoleSymfony version 2.5.3 - app/dev/debug
Usage: [options] command [arguments]
Options: --help -h Display this help message. --quiet -q Do not output any message. --verbose -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for --version -V Display this application version. --ansi Force ANSI output. --no-ansi Disable ANSI output. --no-interaction -n Do not ask any interactive question. --shell -s Launch the shell. --process-isolation Launch commands from shell as a separate process. --env -e The Environment name. --no-debug Switches off debug mode.
Available commands: help Displays help for a command list Lists commandsassetic assetic:dump Dumps all assets to the filesystemassets assets:install Installs bundles web assets under a public web directorycache cache:clear Clears the cache cache:warmup Warms up an empty cacheconfig
This will list every command registered in your application$ app/console | grep twigtwig twig:debug Shows a list of twig functions, filters, globals and twig:lint Lints a template and outputs encountered errors
Combine it with grep
SHORTCUT SYNTAX$ app/console d:s:v
The above is equivalent to:$ app/console doctrine:schema:validate
If the shortcut is ambiguous the console helps you out
COMMANDS ARE SELF DOCUMENTING$ app/console help twig:lint
OTHER GENERAL NOTESAlways be aware of what environment you need to run yourcommand inDon't use interactive mode without a good reason. It will biteyou
THE COMMANDSNOW THAT WE KNOW HOW TO USE THE CONSOLE LETS
EXPLORE THE COMMANDS
ASSETICDumps all your assets (CSS/JS) and applies all configured filters$ app/console assetic:dump
Scans your files for changes and reprocesses any modified files.
Combine this with the following configuration for a hugespeedup in dev
$ app/console assetic:dump --watch
#config.ymlassetic: use_controller: false
ASSETS:INSTALL$ app/console assets:install
Copy Resources/public from every bundle to the webdirectorySymfony has a composer post install/update hook to do this for
you
Tip: put this in your composer.json and you'll never have to runthis command again
"extra": { "symfony-assets-install": "symlink"}
CACHE:CLEAR$ app/console cache:clear
Clears the application cache for a given environment
This is the first thing I try whenever I encounter weirdness
Note the importance of specifying an environment. Each env hasits own cache
CONFIG:DUMP-REFERENCE$ app/console config:dump-reference
First run this without any arguments to see all registered bundles
$ app/console config:dump-reference twig
Then supply a bundle name or alias to view all configurationoptions and defaults
CONFIG:DEBUG$ app/console config:debug
Very similar to config:dump-reference except that it shows youractual configuration
$ app/console config:debug twig
Like the last command you can then view the configuration for abundle
CONTAINER:DEBUG$ app/console container:debug
I use this heaps with grep$ app/console container:debug | grep form
Also useful:$ app/console container:debug --tag=form.type
GENERATE:BUNDLE$ app/console generate:bundle
This is the first thing I do when starting a new project
DOCTRINE:GENERATE:ENTITY$ app/console doctrine:generate:entity
Fantastic for quickly stubbing out entities on the command line
Demo!
DOCTRINE:GENERATE:CRUD$ app/console doctrine:generate:crud
Creates a form type, controller and templates
Another massive timesaver
DOCTRINE:GENERATE:ENTITIES$ app/console doctrine:generate:entities
Creates entity class from your mapping
The secret trick is it safely updates existing entities too!
OTHER HANDY DOCTRINE COMMANDSdoctrine:database:create Creates the configured databasesdoctrine:database:drop Drops the configured databasesdoctrine:mapping:convert Convert mapping information between supported formats.doctrine:mapping:import Imports mapping information from an existing databasedoctrine:mapping:info Shows basic information about all mapped entitiesdoctrine:query:dql Executes arbitrary DQL directly from the command line.doctrine:query:sql Executes arbitrary SQL directly from the command line.doctrine:schema:create Executes (or dumps) the SQL needed to generate the database schemadoctrine:schema:drop Executes (or dumps) the SQL needed to drop the current database schemadoctrine:schema:update Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadatadoctrine:schema:validate Validates the doctrine mapping files
SECURITY:CHECK$ app/console security:check
Sends your composer.lock file to the to see if any dependencies have know security issues
SensioLabs SecurityChecker
Work this in to your CI environment!
SERVER:RUN$ app/console server:run
Spin up a webserver on Single threaded, so serving assets takes a whilePHP 5.4+It should go without saying but don't use this in production!
localhost:8000
THANKS