Coding Standard - EmamulHassan/Travel_Management_-System-TMS GitHub Wiki
To write PHP code, we need both, opening and closing tags, which are <?php and ?> which determines PHP to start and stop interpreting the code between them.
Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.
<?php
$var = 'CSE';
$Var = 'EEE';
echo "$var, $Var"; // outputs "CSE, EEE"
$4site = 'not yet'; // invalid; starts with a number
$_4site = 'not yet'; // valid; starts with an underscore
$täyte = 'mansikka'; // valid; 'ä' is (Extended) ASCII 228.
?>
Model name MUST be declared in PascalCasing.
Feedback.php, TaskModel.php
Controller name MUST be declared in PascalCasing.
TaskController.php, BranchController.Php, FeedbackReadController.php
User-Defined Function names MUST be declared in camelCase(). but we have to use smallcasing and detailed function names while making a function for feature testing.
Inside controller, we will use the pre-defined functions created from Laravel resources.
index(), create(), store(Request $request), edit($id).
User-Defined Function names MUST be declared in camelCase(). but we have to use smallcasing and detailed function name while making a function for feature testing.
branch_can_be_added_through_form(), feedback_can_be_added_through_form().
We will use image intervention if we work with images and Larecipe for documentation tool purposes.
Namespaces and classes MUST follow an "autoloading" PSR: [PSR-0, PSR-4]. This means each class is in a file by itself and is in a namespace of at least one level: a top-level vendor name. Class names MUST be declared in StudlyCaps. Code written for PHP 5.3 and after MUST use formal namespaces.
<?php
namespace Vendor\Model;
class Foo
{}
?>
Conditional statement should be like shown in example.
@if (condition)
//statements
@endif
Inside blade templating commenting will be done like this {{-- comment--}}.
Indentation should always reflect logical structure. Use real tabs and not spaces, as this allows the most flexibility across clients.
[tab]$foo = 'somevalue';
[tab]$foo2 = 'somevalue2';