About Features Downloads Getting Started Documentation Events Support GitHub

Love VuFind®? Consider becoming a financial supporter. Your support helps build a better VuFind®!

Site Tools


Warning: This page has not been updated in over over a year and may be outdated or deprecated.
development:coding_standards

This is an old revision of the document!


Coding Standards

PHP

VuFind uses the PEAR Coding Standards for its PHP code. Several additional recommendations are enforced using the php-cs-fixer tool. For help with standards compliance, see the recommended tools page.

Javascript

ESLint style enforcement in progress. Will use ESLint recommended with a few extra rules. Join in the conversation on this pull request.

Templates

Templates are looser with their styles due to the difficult mix of conditional PHP, HTML, and inline JS. Here's a few guidelines to help write clearer templates.

  • 2 Space Indents
  • Long php tags - <?php
  • Use short echo tags - <?=$var ?>
  • Use if blocks instead of brackets and indent inside - <?php if(): ?><?php endif; ?>
  • Use Slots to simply buffering and conditional content, especially across templates
  • If a loop is producing multiple buttons, links, etc. per item, consider making a subtemplate and using <?=$this→render() ?>
  • Don't call Model methods from Views, perform this logic in the Controllers

CSS

No strict coding practices enforced, although the Code Guide by Bootstrap creator Mark Otto is a recommended read.

Editor Config

# editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.php]
indent_size = 4
development/coding_standards.1596118184.txt.gz · Last modified: 2020/07/30 14:09 by crhallberg