Naming Convention

Table of contents

Loading...

Root-level directories

From php-pds/skeleton

If a package has a root-level directory for ... ... then it MUST be named:
command-line executables bin/
configuration files config/
documentation files docs/
web server files public/
other resource files resources/
PHP source code src/
test code tests/

General files and folders outside src/

Backend project files and folders in src/

Actions

Please see Naming Action classes.

Templates

HTML elements

Tests

Test functions

Providers

Providers are in the folder "Provider" at the root of the /tests folder. The same providers may be used by both unit and integration tests.
Each are in sub folders with the module name.

All providers MUST end with Provider: ClientCreateProvider.

Provider functions may end with the word Provider, Cases or Values depending on the type of provider and preference of the developer.

Fixtures

Fixtures are in the tests/Fixture folder and the class name MUST end with Fixture: UserFixture.php.

Fixtures MUST implement the TestTraits\Interface\FixtureInterface.

Database

Standard API JSON response format

Success

Note: mandatory "data" (null if nothing)

{
  "status": "success",
  "data": {
    "posts": [
      {
        "id": 1,
        "title": "A blog post",
        "body": "Some useful content"
      },
      {
        "id": 2,
        "title": "Another blog post",
        "body": "More content"
      }
    ]
  }
}

Error

Note: "data" is not mandatory but always welcome.

Note 2: HTTP Code also in the response body would be overkill as we have already the information from the HTTP response.

{
  "status": "error",
  "message": "Validation error",
  "data": {
    "errors": {
      "first_name": ["Minimum length is 2"],
      "email": ["Invalid email"]
    }
  }
}

Warning

There is no warning entry in the jsend documentation, but I find it useful sometimes.


{
  "status": "warming",
  "message": "User wasn't updated"
}

References: