The EuroCMS Standards
| Author | release | date |
|---|---|---|
| Imri Paloja | Concept | 19-06-2022 |
Code
Here are the EuroCMS coding standards. There are a million and one way to structure PHP code. The one and only true requirement for writing working code, is writing it in the proper syntax.
The below mentioned standards are something I(Imri Paloja) invented.
Code wise, where possible, it tries to adhere to different coding standard: D.R.Y., MVC, PSR. The operative word being *tries*. Sometimes in practice you have to make little changes here and there to make things fit the design.
I try to prevent Redundant Code, Dead Code, Unreachable code, Duplicate code, Code bloat
In the future there will be coding standards for PHP, CSS, JS and so on.
Fill out these categories:
-
Indenting and Line Length
-
Control Structures
-
Function Calls
-
Class Definitions
-
Function Definitions
-
Arrays
-
Comments
Looking at https://en.wikipedia.org/wiki/PHPDoc for proper commenting. https://docs.phpdoc.org/3.0/guide/internals/project-management.html.
-
Including Code
-
PHP Code Tags
-
Header Comment Blocks
-
Example URLs
-
Naming Conventions
-
File Formats
-
E_STRICT-compatible code
-
Error Handling Guidelines
-
Best practices
-
Sample File (including Docblock Comment standards)
Structure
This is a rough explanation of the structure of the code and what they do.
Engine
The Engine class is the engine that powers EuroCMS. In the load.php, the Engine class resides. That does the loading of all the code, and the code that's needed for the content to load.
The module, widgets, theme components are all structured in an MVC like format. Here is a basic folder and file structure of the Files module:
- controller/Files.mod.php
Contains the class ActiveModule. in this class, there resides functions needed by the Files module.
- tmpl/Files.cont.php
This contains the html structure of the Files module.
- css/Files.cont.css
This contains the needed styling for the Files module.
- js/Files.js.cont.js|Files.bottom.cont.js
Files.js.cont.js will the loaded in the top(<head></head>) html tag.
Those 4 are the MVC component. The following are optional.
- ajax/
If you have an Ajax requests that is needed, you can add your files here: Files.ajax.php. You need to properly register the ajax request.
- docs/Files.docs.md,Files.docs.features.md
You can view the Files.docs.md file completely, or you can create multiple Files.docs.features.md files, which you can view from the feature in question from the fontend.
- lang/Files.lang.en-US.php
The language header will be read from browser, and such the lang/ directory will check for all the language file that the browser requested.
If the requested file is not available it will fall back to en-US. or The only one available.
- files/
For any files you may need. pdf, docs,images, whatever
- handlers/
Handlers are handlers that can be handled in multiple ways.
In the context of the Files module, you way want to have the option to upload to the local server or WebDAV.
So, you have a Local Handler, and a WebDAV handler. In the settings you can switch from Local and WebDAV.
You would have two files, in PHP abstract: Files.handler.WebDAV.php and Files.handler.Local.php.
The Widgets, Modules, Themes all have the similar MVC-ish folder structures.
functions
The standards for the functions to be used where possible
- return should always be a json
The code that accessed the function, should be left to handle the output.
classes
- ACL check
Functions are to small to implement ACL checks, a PHP class should always have a ACL check. Preferably in the __construct()