This is work in progress!
"ootstra" is inspired by Bigfork’s quickstart recipe for Silverstripe. It's an opinionated set of tools for a ready to run, build & deploy a CMS instance. To get it up and running you'll need GIT, an editor like VSCode (recommended) & ddev. It utilizes dnadesign/silverstripe-elemental for a block/element based CMS experience and comes with the following set of elements:
- ElementContent
- ElementForm (userforms)
- ElementVirtual
- ElementHero (Slider, YouTube Video)
- ElementMaps (Google)
- ElementPerso (URLs Perso, vCard)
- ElementPersoCFA (linked persos)
- ElementContentSection (accordion with FAQ schema)
- ElementCounter
- ElementLogo (partner/sponsor)
- ElementGallery (lightbox, slider)
- ElementTeaser
- ElementFeedTeaser (holder concept with multiple parents & filtering per tags)
- ElementTextImage
- ElementPDFDocument PDF Download with preview & description
Optional, separate modules/elements:
- InstagramFeed
- ElementJobs lerni/jobpostings (privat), schema.org & sitemap.xml integration
- lerni/simplebasket (privat), Google Shoppingfeed with local Inventory, swissQR bill and CAMT payment reconciliation or Datatrans Payments
Other features:
- DSGVO, GDPR, nDSG ready, Cookie Consent with klaro!
- Multilingual ready in minutes with fluent
- Elemental based Blog
- schema.org integration with spatie/schema-org
- Meta & OpenGraph integration & MetaOverviewPage
- depending on content close to 100 Google PageSpeed Score
- Google Analytics & Tagmanager, Microsoft Clarity, sitemap.xml, robots.txt
- etc.
Per .vscode/extensions.json
extensions 'll be suggested. .vscode/settings.json
makes Logviewer work and contains settings for debugging etc.
- Silverstripe
- PHP Intelephense
- PHP Debug
- Log Viewer Side-Bar Debug -> Log Viewer
- Debugger for Firefox
- EditorConfig for Visual Studio Code
- Prettier - Code formatter
- Auto Rename Tag
- npm Intellisense
- ESLint
- Sass
git clone git@github.com:lerni/ootstra.git "PROJECT"
On the first request database structure 'll automatically be generated - it runs dev/build
. Before you do so, set the correct default locale in app/_config.php
like:
i18n::set_locale('de_CH');
By default foldername is used as projectname, this is recommended because .vscode/launch.json
uses ${workspaceFolderBasename}
. Run ddev config
in the project directory. Now you're ready to run ddev start
& ddev composer i
. This provides a webserver at https://PROJECTNAME.ddev.site, phpMyAdmin at https://PROJECTNAME.ddev.site:8037, and Mailpit at https://PROJECTNAME.ddev.site:8026/. Default login at /admin is admin
& password
.
This setup omits ddev-ssh-agent
and exposes SSH_AUTH_SOCK
from the host system into the web container in order to use local SSH keys. To make that work, key files from ~/.ssh
or the whole directories must be exposed into ddev by creating symlinks in ~/.ddev/homeadditions
. On macOS, the option IgnoreUnknown UseKeychain
in ~/.ssh/config
causes Bad configuration option
in the container, so symlinking individual files from ~/.ssh/
into ~/.ddev/homeadditions
and having a separate/copy of ~/.ddev/homeadditions/.ssh/config
worked for me ;)
For more information, refer to the ddev documentation & OpenSSH updates in macOS, DDEV issue
UserKnownHostsFile=~/.ssh/known_hosts
StrictHostKeyChecking=accept-new
Host *
ForwardAgent yes
To use use ddev-ssh-agent
instead, following configuration in .ddev/config.yaml
can be removed and .ddev/docker-compose.ssh-agent.yaml
can be deleted.
omit_containers: [ddev-ssh-agent]
webimage_extra_packages: [openssh-client]
web_environment:
- SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
Laravel Mix (webpack based) is used as build environment. You need to run ddev theme install
to install npm packages. Watcher browsersync/reload can be started with ddev theme watch
and 'll be available at https://PROJECTNAME.ddev.site:3000/. A production build can be done with ddev theme prod
. See also scripts section in themes/default/package.json
and Mix CLI.
There are a bunch of tasks in .vscode/tasks.json
available per Command+Shift+B
:
ddev start
(magenta)ddev stop
(magenta)ddev restart
(magenta)composer install
(magenta)composer update
(magenta)ddev log web
(magenta)xdebug on / off
(magenta)ddev theme install
(green)ddev theme watch
(green)ddev theme prod
(green)dev/build
(blue) instead ofddev php ./vendor/silverstripe/framework/cli-script.php dev/build flush
composer vendor-expose
(blue)ssshell
(blue) instead ofddev php ./vendor/bin/ssshell
download database from live
(cyan)download assets from live
(cyan)ssh test / live
(cyan)deploy test / live
(cyan)deploy:unlock test / live
(cyan)dep releases test / live
(cyan)
Colors group tasks like:
- magenta: local ddev
- blue: local silverstripe specific
- green: local npm
- cyan: remote server
Database, credentials etc. are provided as environment-variables from .ddev/config.yaml
and are populated in /.env
during DDEV-start. Project specific / sensitive env-vars should be set in /.env
and won't land in GIT. For example you do not have to setup DB credentials for dev environment to work, but you need to set APP_GOOGLE_MAPS_KEY
, SS_NOCAPTCHA_SITE_KEY
& SS_NOCAPTCHA_SECRET_KEY
in .env
order to make Google Maps & reCaptcha work.
Current used PHP-Version is 8.3. It's set in following places:
.ddev/config.yaml
deploy/config.php
public/.htaccess
-> watch out if stage specific versions are maintained indeploy/
composer.json
.vscode/settings.json
Don't forget to ddev restart
and update packages ddev composer u
after changing!
Deployment is based on Deployer, a php based cli-tool, which is included as dev-requirement per composer.json
. It uses symlinks to the current release. It's easy to use, offers zero downtime deployments and rollback. /assets
, .env
are shared resources, this means they are symlinked into each release-folder. On remote servers you'll need SSH & git, composer, same php-version on CLI as httpd, ln, readlink, realpath, rsync, sed & xargs.
~/public_html/0live or ~/public_html/0test
|
|--.dep
| |--releases deployers internal notes
|
|--current -> ~/public_html/0live/releases/3 for example
| |--.env -> ~/public_html/0live/shared/.env
| |--... all the files from repo & vendors
| |--public actual webroot but symlinked per parent-dir (current)
| | |--assets/ -> ~/public_html/0live/shared/assets
|
|--releases
| |--1
| | |--.env -> ~/public_html/0live/shared/.env
| | |--...
| |
| |--2
| | |--.env -> ~/public_html/0live/shared/.env
| | |...
| |
| |--... as many as defined in keep_releases
|
|--shared
|--public/assets
|--.env
You need to add your public key on remote servers in ~/.ssh/authorized_keys. On nix-based systems you can use ssh-copy-id to do so.
Rename config.example.php
to deploy/config.php
and configure things to your needs. Usually .htaccess
in public comes from the repo but if needed, it can be overwritten with a stage specific version. Just create ./deploy/test.htaccess
or ./deploy/live.htaccess
, which than 'll overwrite public/.htaccess
during deployment according to the stage in use.
Key-forwarding is used, allowing deployment to be done from inside the ddev-web container. Read ddev-ssh-agent above. Before first deployment, SSH into remote servers like ddev php ./vendor/bin/dep ssh test
or ddev php ./vendor/bin/dep ssh live
and ensure the SSH fingerprint from the git-repo is accepted. You can check with ssh -T git@domain.tld
or may just git clone ...
into a test directory to verify everything works as expected. If so, deployment is done as follows:
ddev php ./vendor/bin/dep deploy test
or
ddev php ./vendor/bin/dep deploy live
The first time you deploy to a given stage, you’ll be asked to provide database credentials etc. to populate .env
. A file similar as below 'll be created.
# For a complete list of core environment variables see
# https://docs.silverstripe.org/en/4/getting_started/environment_management/#core-environment-variables
# APP_GOOGLE_MAPS_KEY=''
# SS_NOCAPTCHA_SITE_KEY=''
# SS_NOCAPTCHA_SECRET_KEY=''
# Environment dev/test/live
SS_ENVIRONMENT_TYPE='dev'
# SS_BASE_URL=''
# SS_DEFAULT_ADMIN_USERNAME=''
# SS_DEFAULT_ADMIN_PASSWORD=''
SS_ERROR_EMAIL=''
SS_ADMIN_EMAIL=''
## Database {#database}
SS_DATABASE_NAME='db'
# SS_DATABASE_CHOOSE_NAME=true
SS_DATABASE_CLASS='MySQLDatabase'
SS_DATABASE_USERNAME='db'
SS_DATABASE_PASSWORD='db'
SS_DATABASE_SERVER='db'
SS_DATABASE_PORT='3306'
SS_ERROR_LOG='silverstripe.log'
GHOSTSCRIPT_PATH='/usr/bin/gs'
SCRIPT_FILENAME=''
# Deploy revision (git SHA) to test
ddev php ./vendor/bin/dep deploy --revision=ca5fcd330910234f63bf7d5417ab6835e5a57b81 test
# Deploy dev branch to test
ddev php ./vendor/bin/dep deploy --branch=dev test
# Deploy tag 1.0.1 to live
ddev php ./vendor/bin/dep deploy live --tag=1.0.1 live
ddev php ./vendor/bin/dep releases live
task releases
+----------------------+-------------+-------- live ---+------------------------------------------+
| Date (Europe/Zurich) | Release | Author | Target | Commit |
+----------------------+-------------+--------+--------+------------------------------------------+
| 2022-11-21 16:57:41 | 1 | user | HEAD | 089d9397c34f0c478059a09470000006ed41e000 |
| 2022-12-01 16:06:45 | 2 | user | HEAD | 007300b9e054675050d0d1de7000000444918000 |
| 2022-12-02 10:41:18 | 3 (current) | user | HEAD | 0d2f7df3fbbc53f666366c3cf000000a392f3000 |
+----------------------+-------------+--------+--------+------------------------------------------+
... or use VSCode tasks Command+Shift+B
# Upload database to test
ddev php ./vendor/bin/dep silverstripe:upload_database test
# Download database from live
ddev php ./vendor/bin/dep silverstripe:download_database live
etc.
or use VSCode tasks Command+Shift+B
# Download assets from live
dep silverstripe:download_assets live
# Upload assets to test
dep silverstripe:upload_assets test
etc.
or use VSCode tasks Command+Shift+B
DevelopmentAdmin over HTTP is disabled in Live-Mode per yml-config. Following deployer-tasks 'll do.
# dev/build on live
ddev php ./vendor/bin/dep silverstripe:dev_build live -v
# dev/build on test
ddev php ./vendor/bin/dep silverstripe:dev_build test -v
ootstra
is licensed under the BSD license. Third-party modules have different licenses like (0BSD, Apache 2.0, Apache-2.0, BSD*, BSD-2-Clause, BSD-3-Clause, CC-BY-3.0, CC-BY-4.0, CC0-1.0, GPL-2.0, GPL-3.0+, GPL-3.0-or-later, ISC, MIT, MIT*, Zlib, etc.). Check with composer licenses
, npx license-checker --summary
in themes/default
and be aware of the suggested plugins for VSCode. Use implies acceptance of all licenses. Note that @fancyapps/ui is commercial software requiring a purchased license.