Grunt plugin for running Symfony2 commands.
This plugin requires Grunt ~0.4.4
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-symfony2 --save-dev
Once you installed the plugin you can enable it inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-symfony2');
The sf2-console
task let's you execute arbitrary commands of your Symfony2 application.
In your project's Gruntfile, add a section named sf2-console
to the data object passed into grunt.initConfig()
.
'sf2-console': {
options: {
// Task-specific options go here.
},
your_target: {
cmd: 'command:name',
args: {
// Arguments
}
}
}
Type: String
Default value: app/console
Path to console application that you want to use.
grunt-symfony2
uses by default app/console
as binary to execute commands.
'sf2-console': {
options: {},
cache_clear_prod: {
cmd: 'cache:clear',
args: {
env: 'prod'
}
}
}
If you want to use a custom binary, you can change the bin
option.
'sf2-console': {
options: {
bin: 'app/sf2console'
},
cache_clear_prod: {
cmd: 'cache:clear',
args: {
env: 'prod'
}
}
}
The execution environment of a task can be auto detected based on the target. If the targets name is either prod
,
dev
or staging
and the env
argument is not present the task uses the target name as environment.
The following task executes automatically in prod
environment.
'sf2-cache-clear': {
options: {},
prod: {}
}
grunt-symfony2
contains additional tasks that allow you to quickly execute Symfony2 commands from grunt. The tasks
work exactly like the sf2-console
task, you just don't need to provide the cmd
option. Arguments and auto detection
of the environment are also supported. Currently we support the following commands:
- sf2-assetic-dump:
assetic:dump
- sf2-assets-install:
assets:install
- sf2-cache-clear:
cache:clear
- sf2_cache_warmup:
cache:warmup
- sf2-doctrine-cache-clear-metadata:
doctrine:cache:clear-metadata
- sf2-doctrine-cache-clear-query:
doctrine:cache:clear-query
- sf2-doctrine-cache-clear-result:
doctrine:cache:clear-result
- sf2-doctrine-database-create:
doctrine:database:create
- sf2-doctrine-database-drop:
doctrine:database:drop
- sf2-doctrine-ensure-production-settings:
doctrine:ensure-production-settings
- sf2-doctrine-fixtures-load:
doctrine:fixtures:load
- sf2-doctrine-migrations-diff:
doctrine:migrations:diff
- sf2-doctrine-migrations-execute:
doctrine:migrations:execute
- sf2-doctrine-migrations-generate:
doctrine:migrations:generate
- sf2-doctrine-migrations-latest:
doctrine:migrations:latest
- sf2-doctrine-migrations-migrate:
doctrine:migrations:migrate
- sf2-doctrine-migrations-status:
doctrine:migrations:status
- sf2-doctrine-migrations-version:
doctrine:migrations:version
- sf2-doctrine-schema-create:
doctrine:schema:create
- sf2-doctrine-schema-drop:
doctrine:schema:drop
- sf2-doctrine-schema-update:
doctrine:schema:update
- sf2-doctrine-schema-validate:
doctrine:schema:validate
- sf2-orm-convert-mapping:
orm:convert:mapping
- sf2-translation-update:
translation:update
- sf2-twig-lint:
twig:lint
Set the value to true
if you want to use an option without value:
'sf2-doctrine-schema-update': {
dev: {
args: { force: true }
}
}
It's a little bit confusing, but you have to put arguments (speaking in Symfony2 console terms) outside of the args
array.
'sf2-orm-convert-mapping': {
dev: {
'to-type': 'xml',
'dest-path': 'src/Acme/DemoBundle/Entity'
},
options: {
bin: 'test/fixtures/console'
}
}
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
- Show output of Sculpin in Grunt output
- Added support for arguments in tasks
- Improved task names
- Additional tests
- Initial release