Deployment
Put a site online, from a simple upload to shared hosting to git with staging and production.
On this page
Lettern runs on ordinary PHP hosting. For a small site, upload it and you're done. For client work with a staging site, keep the design and structure in git and move content with Sync.
#On shared hosting
Upload the zip, open the site in a browser, and setup does the rest. See Installation. Published pages are served straight from files, so the site stays fast on the smallest plan.
Back up the database and the site folder. Everything else can be downloaded again.
#Local, staging and production
Most agencies build on their own machine, show the client a staging site, and run the real one in production. Two kinds of things travel between them, in two ways:
- Design and structure (templates, components, collections, settings) are plain files in
content/andconfig/, so they go through git like code. - Content written in the admin (pages, posts, media) lives in the database. Move it between your machine, staging and production with Sync, in either direction.
#For developers
#Deploy with git
- Commit
composer.json,composer.lock,config/andcontent/, and the plugins you wrote yourself. - On the server, after pulling, run:
composer install --no-dev --optimize-autoloader
php cms sync
php cms build- What people change in the admin on the server, like settings or a collection, is saved to
config/andcontent/there. Commit it from the server, or make the same change locally and deploy it, so the next deploy finds no difference.
Store entries that should be versioned, like documentation or landing pages, in collections with driver: files. Entries in the database (posts written by editors, form submissions) stay on the server, and Sync moves them.
#Environments
Each environment has its own .env: the database, the app key, secrets, and debug off in production. Any setting can be overridden per environment with a CMS_<NAMESPACE>_<KEY> variable, so production credentials never enter git.
#Static hosting and CDNs
After php cms build, public/ is a complete static site. Sync it to a CDN or object storage and keep the admin on a private host. Forms and other live features keep posting to the Lettern server's APIs. See Publishing.
#Scheduled tasks
Nothing needs cron: builds and scheduled publishing run after requests. If you do have cron, run php cms publish:scheduled every minute for exact timing.