How to deploy my Symfony2 project into ftp How to deploy my Symfony2 project into ftp symfony symfony

How to deploy my Symfony2 project into ftp


First off it should be noted that deploying a Symfony2 app over FTP is really really bad. It makes a couple of steps more difficult (or even impossible) and should be avoided. If you have SSH access to the machine look at my list of alternative deployment methods below.

Preparation

There are a few things you cannot influence when you deploy over FTP. If you have no control over the following or can not configure them correctly you unfortunately have no chance of deploying to a shared hosting.

  • The PHP configuration. If settings are not set correctly and you have no chance of changing them you are unfortunately lost.
  • Any PHP module you may require. Same as above. If you can not install any additional modules you need there is no chance for you. (An example for that would be the php5-intl module for any Symfony <2.6)
  • Correct folder permissions. Especially for app/cache and app/logs. Check the docs for requirements.
  • The Webserver configuration. Symfony needs a correctly configured Webserver (in most cases probably apache or nginx) to function correctly. If you can not influence the config this is bad as well. You might want to try to define the rewrite rules in a .htaccess file as described here.

Deployment

Here are the steps you need to follow to prepare your application for deployment for the first time:

  • Update / Install vendors. Use composer install (or composer update) to install any third party bundle or library you use in your project since you have no option to install them later directly on the server.
  • If you use Assetic for your asset management, make sure you install these as well with the php app/console assetic:dump --env=prod command.
  • Dump any other assets like so: php app/console assets:install --env=prod. (This step might not be required but you need to make sure the assets are not symlinked. Check this blog post if you are using symfony >=2.6)
  • Clear the cache for production: php app/console cache:clear --env=prod
  • Make sure you edit your parameters.yml to fit the needs of your production server.
  • Also update your database schema on your production database in case you have changed it during development.

Now you should be good to go. Copy the whole folder onto your server and try it out.

For the future

If you deploy for the second time make sure not to override any user data (e.g. uploaded images). Also you need to clear the cache over ftp. To do that empty the app/cache directory.

Alternative deployment methods

In case you have more access to the server check out any of these. They might fit your needs better than old pure FTP. Maybe they give you reason enough to change to a more appropriate server. Capifony is probably one of the best deployment tools for Symfony2 apps. Deployment will be as easy as running cap deploy on your local machine. The rest is magic ;) Simple git is also possible for deployment. Many of the above steps will still apply but you have all the advantages git gives you like not copying everything every time you deploy. A very good list of all tools can be found in the docs.


It might help if you tell us a little more about your server set up, but here's a fairly generic guide:

  1. Assuming you want to upload it using ftp (since you tagged the question as such), you will need an FTPclient (see here for some suggestions).

  2. Using the FTP client, you'll want to connect to your server(hostname: yoursite.com) using your credentials (if it is a securedserver).

  3. From there, you should be able to upload any files from your localmachine to the server.

More specific directions will depend on your server configuration and the FTP client you choose (it should come with its own manual)