Frontastic coding guide
When working with Frontastic you can, in general, follow your own coding guidelines. However, some rules are needed for your code to function properly with Frontastic which we'll go through in this article. On top of that, we recommend some additional guidelines which will help you streamline your development workflow with Frontastic.
Frontastic automatically builds pushes to the
master branch. Those builds will be tested and, if successful, compiled assets will be available for deployment.
This doesn't mean that you can't use branches. However, branches will only be tested when pushed to the remote origin and no assets will be compiled (see the deployment article for more information).
master build will also automatically be deployed to staging (if you didn't explicitly request this to be turned off) and be available for rollout to production through the Frontastic studio.
Frontastic suggests a ‘master-based development flow’ (originally known as ‘trunk-based development’). This means branches are generally discouraged. All code should go directly into
master. This requires each push (ideally each commit) to leave the codebase fully functional. Feature flagging and branch-by-abstraction are programming techniques to make this possible. With that, your team will benefit from a faster, more agile development workflow.
We also suggest following these rules for a smooth setup:
- Pull before you push
- Rebase unpushed changes in favor of merge (set
- Structure your work in logical steps and commit parts of your work together which deal with a common purpose
- Frequent, smaller commits are preferred over large batches of work
- Push frequently, but always ensure a working state in
Code in Frontastic projects and your customer directory should be organized as follows:
src/contains all source code divided by programming language
test/includes all tests in the same structure as used in
config/holds the global project configuration
public/is publically accessible through the web server and should only contain the main code entry points & assets
Testing and code verification
Frontastic comes with a build system that allows you to run all steps within a Frontastic sandbox. To run all tests of all of your projects you can SSH into the sandbox and run the below command:
environment file or adjusting
build.xml (see the extending the build system article for more information).
PHP coding conventions
The following conventions are strongly advised to be applied to PHP backend code.
The following PSR (PHP Standardization Request) must be followed:
Besides that, we're using Symfony 4.1 in all of our PHP-based components and attempt to follow its rules.
Updated about 1 year ago