# How to deploy my slim rest api online?

**URL:** <https://discourse.slimframework.com/t/how-to-deploy-my-slim-rest-api-online/3054>\
**Category:** Questions\
**Created:** [March 23, 2019, 3:35am UTC](https://discourse.slimframework.com/t/how-to-deploy-my-slim-rest-api-online/3054 "2019-03-23T03:35:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Testosiste](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@Testosiste](https://discourse.slimframework.com/u/Testosiste)\
**Post date:** [March 23, 2019, 3:35am UTC](https://discourse.slimframework.com/t/how-to-deploy-my-slim-rest-api-online/3054/1 "2019-03-23T03:35:25Z")

</div>

Hi  
Please, I would like to know how to proceed to put my API slim on an online server once the local development is finished …

By ftp? or how ?  
Thanks for your help

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [March 23, 2019, 10:29am UTC](https://discourse.slimframework.com/t/how-to-deploy-my-slim-rest-api-online/3054/2 "2019-03-23T10:29:10Z")

</div>

That depends on the features you are looking for. Some hosting services like [fortrabbit](https://www.fortrabbit.com) will take care of it for you via Git. Others like [Beanstalk](https://beanstalkapp.com) or [DeployBot](https://deploybot.com) will handle SFTP (and other transfers) for you. Or you can do it manually via SFTP, or use something like rsync.

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [March 24, 2019, 10:47am UTC](https://discourse.slimframework.com/t/how-to-deploy-my-slim-rest-api-online/3054/3 "2019-03-24T10:47:49Z")

</div>

It depends on the server setup/environment.

For deployment on a productive server, there are some important settings and security releated things to consider.

You can use composer to generate an optimized build of your application. All dev-dependencies are removed and the Composer autoloader is optimized for performance.

```auto
composer install --no-dev --optimize-autoloader

```

Furthermore, you should activate caching for Twig to increase the performance of the template engine.

Routing can also be accelerated by using a [cache file](https://akrabat.com/slims-route-cache-file/).

Set the option `displayErrorDetails` to `false` in production.

[Read more](https://odan.github.io/2017/11/30/creating-your-first-slim-framework-application.html#deployment)

Then I would create a so called “artifact” in form of a ZIP (or whatever you want) file. You can upload this single file (much faster) via FTP/SFTP/FTPS. On the server, the archive is getting extracted and the old application directory replaced by the new applications directory. If necessary, you can perform database migrations at the end.

---

<div class="post-metadata">

**Author:** ![Testosiste](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@Testosiste](https://discourse.slimframework.com/u/Testosiste)\
**Post date:** [March 24, 2019, 8:04pm UTC](https://discourse.slimframework.com/t/how-to-deploy-my-slim-rest-api-online/3054/4 "2019-03-24T20:04:45Z")

</div>

Thank so much.

I would like to ask if your recommendation is useful for an api rest for an Android application…

Because I am developping the api for it.

If your have a link Which explains how to do it ant the different step please help me.

PS: l’m beginner, so thank

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [March 25, 2019, 9:44am UTC](https://discourse.slimframework.com/t/how-to-deploy-my-slim-rest-api-online/3054/5 "2019-03-25T09:44:25Z")

</div>

For the beginning I would recommend to learn something about [Continuous delivery](https://en.wikipedia.org/wiki/Continuous_delivery) and [Continuous deployment](https://en.wikipedia.org/wiki/Continuous_deployment)

This book is very good: [Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation, Video Enhanced Edition](https://www.amazon.com/Continuous-Delivery-Deployment-Automation-Addison-Wesley/dp/0321601912).

Video from Javier Lopez: [Continuously delivering PHP projects](https://www.youtube.com/watch?v=HOwPJg-F4h0)

More links about CI and CD

- [What’s Continuous Deployment?](https://www.sitepoint.com/whats-continuous-deployment/)
- [PHP and Continuous Integration with Travis CI](https://www.sitepoint.com/php-continuous-integration-travis-ci/)
- [Continuous Integration](https://stackoverflow.com/questions/28608015/continuous-integration-vs-continuous-delivery-vs-continuous-deployment/28628086#28628086)

I’m building artifacts with [Apache Ant](https://ant.apache.org/) ([build.xml](https://github.com/odan/prisma/blob/master/build.xml#L142)) and deploy it with a tiny php script ([deploy.php](https://github.com/odan/prisma/blob/master/config/deploy.php)) to production.

---

<div class="post-metadata">

**Author:** ![Testosiste](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@Testosiste](https://discourse.slimframework.com/u/Testosiste)\
**Post date:** [March 28, 2019, 10:17am UTC](https://discourse.slimframework.com/t/how-to-deploy-my-slim-rest-api-online/3054/6 "2019-03-28T10:17:35Z")

</div>

Thnak so much…

Plear dear Odan, for this commande

> Blockquote  
> composer update --no-dev --optimized-autoloader  
> Blockquote

I must be in what the project directory before performing it ?

Thank for explanation…

---

<div class="post-metadata">

**Author:** ![Testosiste](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@Testosiste](https://discourse.slimframework.com/u/Testosiste)\
**Post date:** [March 28, 2019, 11:34am UTC](https://discourse.slimframework.com/t/how-to-deploy-my-slim-rest-api-online/3054/7 "2019-03-28T11:34:33Z")

</div>

I have this error by using the command:  
composer update --no-dev --optimized-autoloader

 ![Capture](https://canada1.discourse-cdn.com/flex030/uploads/slimframework/original/1X/8f8f4c2f2ec148671ad79dbd906c5343441f1fcf.png)

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [March 28, 2019, 3:25pm UTC](https://discourse.slimframework.com/t/how-to-deploy-my-slim-rest-api-online/3054/8 "2019-03-28T15:25:29Z")

</div>

Sorry a typo. Try

```auto
composer install --no-dev --optimize-autoloader

```

---

<div class="post-metadata">

**Author:** ![Testosiste](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@Testosiste](https://discourse.slimframework.com/u/Testosiste)\
**Post date:** [March 28, 2019, 9:41pm UTC](https://discourse.slimframework.com/t/how-to-deploy-my-slim-rest-api-online/3054/9 "2019-03-28T21:41:50Z")

</div>

> [@odan](#):
>
> ```auto
> composer install --no-dev --optimize-autoloader
> 
> ```

please, to perform this command i was be in what directory ?

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [March 29, 2019, 6:56am UTC](https://discourse.slimframework.com/t/how-to-deploy-my-slim-rest-api-online/3054/10 "2019-03-29T06:56:59Z")

</div>

Run this command in the same directory as the project’s `composer.json` file.

[https://getcomposer.org/doc/articles/autoloader-optimization.md](https://getcomposer.org/doc/articles/autoloader-optimization.md)
