How to deploy my slim rest api online?

#1

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

0 Likes

#2

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

0 Likes

#3

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.

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.

Set the option displayErrorDetails to false in production.

Read more

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.

0 Likes

#4

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

0 Likes

#5

For the beginning I would recommend to learn something about Continuous delivery and Continuous deployment

This book is very good: Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation, Video Enhanced Edition.

Video from Javier Lopez: Continuously delivering PHP projects

More links about CI and CD

I’m building artifacts with Apache Ant (build.xml) and deploy it with a tiny php script (deploy.php) to production.

0 Likes

#6

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…

0 Likes

#7

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

0 Likes

#8

Sorry a typo. Try

composer install --no-dev --optimize-autoloader
0 Likes

#9

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

0 Likes

#10

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

https://getcomposer.org/doc/articles/autoloader-optimization.md

0 Likes