Skip to content

MacareuxDigital/coding-standards

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

Macareux Digital Coding Standards

Clean Code Concepts for PHP

I think this is a matter of personal taste. When is the code clean? When is it not? This is hard to say, but there are some general guidelines which you can follow to help improve your code. Below I have given the references that I use, and they have helped me so far.

Follow the concrete5 official documentation.

Clean Code PHP(jupeter/clean-code-php), is a guide based on the book Clean Code: A Handbook of Agile Software Craftmanship, a classic programming book about writing maintainable code by Uncle Bob Martin. I recommend this as a Must Read guideline.

Check their official documentation to integrate with your IDE. Also, concrete5 has a command (from 8.5.3) to use it. Please run ./concrete/bin/concrete5 c5:phpcs --help for detail.

👉Tips & Tricks

Package development

The followings are the basic requirements when you make a package-

👉Config

  • Contents (Block Types, Single Pages, Express Objects etc.) can be installed Programmatically or using CIF files. CIF is the recommended way to use.
  • Add an example config file (if any). e.g., example.concrete.php

👉Routes

  • Follow the official guide to send data to and from a controller into the page view. Please avoid using ajax unnecessarily.

I've created this skeleton package as a starting point to develop packages. You can get ideas from here. Feel free to make a pull request to improve this repository.

Performance

  • Avoid duplicate MySQL queries.
  • Use Object Caching to improve performance.

Test

  • Write PHPUnit tests to test your package.

Documentation