{"_id":"573ed4bfa233380e005db15d","user":"56b86c990094520d006b3c33","__v":0,"category":{"_id":"573ed4bea233380e005db150","__v":0,"version":"573ed4bea233380e005db14d","project":"56b86cc286d2b0190070bcda","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-05-18T10:34:59.134Z","from_sync":false,"order":3,"slug":"cookbook","title":"cookbook"},"githubsync":"","project":"56b86cc286d2b0190070bcda","parentDoc":null,"version":{"_id":"573ed4bea233380e005db14d","__v":2,"project":"56b86cc286d2b0190070bcda","createdAt":"2016-05-20T09:11:26.847Z","releaseDate":"2016-05-20T09:11:26.847Z","categories":["573ed4bea233380e005db14e","573ed4bea233380e005db14f","573ed4bea233380e005db150","578bcf36bb7d810e00e01c05"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"master","version_clean":"0.3.0-0.4","version":"0.3-0.4"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-05-18T10:35:28.742Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"This guide provides you with the basic steps to install and deploy a Symfony application from a public or private VCS repository.\n\n1. [Creating an Accompli configuration file](#section-1-creating-an-accompli-configuration-file).\n2. [Adding SSH authentication for access to private repositories](#section-2-adding-ssh-authentication-for-access-to-private-repositories).\n3. [Adding authentication to Composer dependency installation](#section-3-adding-authentication-to-composer-dependency-installation).\n4. [Additional tasks (eg. database migrations)](#section-4-additional-tasks-eg-database-migrations-).\n\n\n## 1. Creating an Accompli configuration file\nSee the [configuration](configuration) documentation on how to create a basic `accompli.json` configuration file.\n\nAccompli provides the following recipes to ease the configuration of a Symfony project deployment:\n\n* [Symfony](https://github.com/accompli/accompli/blob/master/src/Resources/recipe/symfony.json).\n* [Symfony with assets](https://github.com/accompli/accompli/blob/master/src/Resources/recipe/symfony-with-assets.json).\n\nA minimal Accompli configuration for a Symfony project could look like this:\n\n``` json\n{\n    \"$extend\": \"accompli://recipe/symfony-with-assets.json\",\n    \"hosts\": [\n        {\n            \"stage\": \"test\",\n            \"connectionType\": \"ssh\",\n            \"hostname\": \"my-symfony-project.com\",\n            \"path\": \"/var/www/my-symfony-project\"\n        }\n    ],\n    \"events\": {\n        \"subscribers\": [\n            {\n                \"class\": \"Accompli\\\\Task\\\\ExecuteCommandTask\",\n                \"events\": [\"accompli.prepare_release\"],\n                \"command\": \"ssh-keyscan github.com >> ~/.ssh/known_hosts\"\n            },\n            {\n                \"class\": \"Accompli\\\\Task\\\\RepositoryCheckoutTask\",\n                \"repositoryUrl\": \"git:::at:::github.com:my-username/my-symfony-project.git\"\n            },\n            {\n                \"class\": \"Accompli\\\\Task\\\\ComposerInstallTask\"\n            },\n            {\n                \"class\": \"Accompli\\\\Task\\\\YamlConfigurationTask\",\n                \"configurationFile\": \"/app/config/parameters.yml\",\n                \"configuration\": {\n                    \"parameters\": {\n                        \"database_name\": \"My_database_%stage%\",\n                        \"database_password\": \"MyDatabasePassword\"\n                    }\n                },\n                \"generateValueForParameters\": [\n                    \"parameters.secret\"\n                ]\n            },\n            {\n                \"class\": \"Accompli\\\\Task\\\\DeployReleaseTask\"\n            }\n        ]\n    }\n}\n```\n\n\n## 2. Adding SSH authentication for access to private repositories\nThe [`SSHAgentTask`](sshagenttask) provides the functionality to create an SSH agent and add private keys on a (remote) host.\n\nSee the following documentation to create and configure SSH deployment keys:\n\n* [GitHub - Generating an SSH key](https://help.github.com/articles/generating-an-ssh-key/).\n* [GitHub - Deploy keys](https://developer.github.com/guides/managing-deploy-keys/#deploy-keys).\n* [GitLab - Deploy keys](http://doc.gitlab.com/ce/ssh/README.html#deploy-keys).\n\nThe generated private key can then be added to the `SSHAgentTask` in your Accompli configuration:\n\n``` json\n{\n    \"class\": \"Accompli\\\\Task\\\\SSHAgentTask\",\n    \"keys\": [\n        \"YOUR\\nPRIVATE\\nKEY\\n\"\n    ]\n}\n```\n\n**Warning!** Don't add private keys to public repositories.\nThe next release of Accompli will feature a credentials store which will make this possible without exposing your keys and passwords.\n\n\n## 3. Adding authentication to Composer dependency installation\nWhen you require authentication for Composer, when installing packages from private servers or reaching the GitHub rate-limit,\nyou can add an authentication configuration to the [`ComposerInstallTask`](composerinstalltask).\n\nThe following is an example of how to configure an GitHub OAuth token:\n\n``` json\n{\n    \"class\": \"Accompli\\\\Task\\\\ComposerInstallTask\",\n    \"authentication\": {\n        \"github-oauth\": {\n            \"github.com\": \"your-oauth-token\"\n        }\n    }\n}\n```\n\n\n## 4. Additional tasks (eg. database migrations)\nAdditional tasks, like Doctrine migrations or other `bin/console` commands, can be executed through the [`ExecuteCommandTask`](doc:executecommandtask).\n\nDoctrine database schema update example:\n``` json\n{\n    \"class\": \"Accompli\\\\Task\\\\ExecuteCommandTask\",\n    \"events\": [\"accompli.deploy_release\"],\n    \"command\": \"php bin/console doctrine:schema:update --env=prod --force\"\n}\n```\n\nDéploiement heureux! / Happy deploying!","excerpt":"","slug":"deploying-your-symfony-application","type":"basic","title":"Deploying your Symfony application"}

Deploying your Symfony application


This guide provides you with the basic steps to install and deploy a Symfony application from a public or private VCS repository. 1. [Creating an Accompli configuration file](#section-1-creating-an-accompli-configuration-file). 2. [Adding SSH authentication for access to private repositories](#section-2-adding-ssh-authentication-for-access-to-private-repositories). 3. [Adding authentication to Composer dependency installation](#section-3-adding-authentication-to-composer-dependency-installation). 4. [Additional tasks (eg. database migrations)](#section-4-additional-tasks-eg-database-migrations-). ## 1. Creating an Accompli configuration file See the [configuration](configuration) documentation on how to create a basic `accompli.json` configuration file. Accompli provides the following recipes to ease the configuration of a Symfony project deployment: * [Symfony](https://github.com/accompli/accompli/blob/master/src/Resources/recipe/symfony.json). * [Symfony with assets](https://github.com/accompli/accompli/blob/master/src/Resources/recipe/symfony-with-assets.json). A minimal Accompli configuration for a Symfony project could look like this: ``` json { "$extend": "accompli://recipe/symfony-with-assets.json", "hosts": [ { "stage": "test", "connectionType": "ssh", "hostname": "my-symfony-project.com", "path": "/var/www/my-symfony-project" } ], "events": { "subscribers": [ { "class": "Accompli\\Task\\ExecuteCommandTask", "events": ["accompli.prepare_release"], "command": "ssh-keyscan github.com >> ~/.ssh/known_hosts" }, { "class": "Accompli\\Task\\RepositoryCheckoutTask", "repositoryUrl": "git@github.com:my-username/my-symfony-project.git" }, { "class": "Accompli\\Task\\ComposerInstallTask" }, { "class": "Accompli\\Task\\YamlConfigurationTask", "configurationFile": "/app/config/parameters.yml", "configuration": { "parameters": { "database_name": "My_database_%stage%", "database_password": "MyDatabasePassword" } }, "generateValueForParameters": [ "parameters.secret" ] }, { "class": "Accompli\\Task\\DeployReleaseTask" } ] } } ``` ## 2. Adding SSH authentication for access to private repositories The [`SSHAgentTask`](sshagenttask) provides the functionality to create an SSH agent and add private keys on a (remote) host. See the following documentation to create and configure SSH deployment keys: * [GitHub - Generating an SSH key](https://help.github.com/articles/generating-an-ssh-key/). * [GitHub - Deploy keys](https://developer.github.com/guides/managing-deploy-keys/#deploy-keys). * [GitLab - Deploy keys](http://doc.gitlab.com/ce/ssh/README.html#deploy-keys). The generated private key can then be added to the `SSHAgentTask` in your Accompli configuration: ``` json { "class": "Accompli\\Task\\SSHAgentTask", "keys": [ "YOUR\nPRIVATE\nKEY\n" ] } ``` **Warning!** Don't add private keys to public repositories. The next release of Accompli will feature a credentials store which will make this possible without exposing your keys and passwords. ## 3. Adding authentication to Composer dependency installation When you require authentication for Composer, when installing packages from private servers or reaching the GitHub rate-limit, you can add an authentication configuration to the [`ComposerInstallTask`](composerinstalltask). The following is an example of how to configure an GitHub OAuth token: ``` json { "class": "Accompli\\Task\\ComposerInstallTask", "authentication": { "github-oauth": { "github.com": "your-oauth-token" } } } ``` ## 4. Additional tasks (eg. database migrations) Additional tasks, like Doctrine migrations or other `bin/console` commands, can be executed through the [`ExecuteCommandTask`](doc:executecommandtask). Doctrine database schema update example: ``` json { "class": "Accompli\\Task\\ExecuteCommandTask", "events": ["accompli.deploy_release"], "command": "php bin/console doctrine:schema:update --env=prod --force" } ``` Déploiement heureux! / Happy deploying!