2013-07-22 34 views
0

的“部署后,”命令我需要创建一个执行命令:如何创建与Symfony2的

$ php app/console cache:clear --env=prod 
$ php app/console composer:update 
$ php app/console doctrine:schema:drop --force 
$ php app/console doctrine:schema:create 
$ php app/console doctrine:fixtures:load .... yes 
$ php app/console assets:dump --env=prod 

你有什么想法? (我尝试过Capifony进行部署过程,但这不是新任务的目的)。

谢谢。

+1

什么? 'alias my_things =“php app/console cache:clear ...; php app/console composer:...' – fedorqui

回答

1

你在Unix/Linux系统上吗?如果是的话,你可以把它们放在一个shell脚本:

#!/bin/sh 
dir="path where Symfony is installed" 
cd "$dir" 
php app/console cache:clear --env=prod 
php app/console composer:update 
php app/console doctrine:schema:drop --force 
php app/console doctrine:schema:create 
php app/console doctrine:fixtures:load .... yes 
php app/console assets:dump --env=prod 
+0

谢谢你,用这种方式完成! – Diego

+0

symfony建议不要使用'php app/console doctrine:schema: drop --force'在生产环境中使用。 https://symfony.com/doc/current/doctrine.html – hayzem

3

如果使用Composer,您可以在composer.json文件的“脚本”部分添加一些后安装的命令,例如(这是一个从标准的symfony分布):

"scripts": { 
    "post-install-cmd": [ 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile" 
    ], 
    "post-update-cmd": [ 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets", 
     "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile" 
    ] 
},