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

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
development:coding_standards [2015/12/11 18:45] – ↷ Links adapted because of a move operation demiankatzdevelopment:coding_standards [2023/03/17 10:43] (current) demiankatz
Line 1: Line 1:
 ====== Coding Standards ====== ====== Coding Standards ======
  
-VuFind uses the [[http://pear.php.net/manual/en/standards.php|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 [[development:recommended_tools#style|recommended tools page]].+===== PHP ===== 
 + 
 +VuFind® currently uses the [[https://www.php-fig.org/psr/psr-12/|PSR-12 standard]] for its PHP code; versions 8.x and earlier were developed using the similar but now outdated [[http://pear.php.net/manual/en/standards.php|PEAR Coding Standards]]. Several additional recommendations are enforced using the php-cs-fixer tool. For help with standards compliance, see the [[development:recommended_tools#style|recommended tools page]]. 
 + 
 +===== Javascript ===== 
 + 
 +ESLint style enforcement is in effect. It uses ESLint recommended rules with a few extra rules. For more information, see [[https://github.com/vufind-org/vufind/pull/700|this pull request]]. 
 + 
 +===== Templates ===== 
 + 
 +Templates are a 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 
 + 
 +Many of these items and more are enforced and automatically corrected with [[https://github.com/FriendsOfPHP/PHP-CS-Fixer|PHP-CS-fixer]]. 
 +===== CSS ===== 
 + 
 +No strict coding practices enforced, although the [[http://codeguide.co/|Code Guide]] by Bootstrap creator Mark Otto is a recommended read. 
 + 
 +===== Editor Config ===== 
 +<code> 
 +# 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 
 +</code>
  
 ---- struct data ---- ---- struct data ----
 +properties.Page Owner : 
 ---- ----
  
development/coding_standards.1449859518.txt.gz · Last modified: 2015/12/11 18:45 by demiankatz